editInV0() — ui Function Reference
Architecture documentation for the editInV0() function in edit-in-v0.ts from the ui codebase.
Entity Profile
Dependency Diagram
graph TD c4bb9c72_bb18_42a5_9e9a_4d568ef28d92["editInV0()"] cd9b6915_a6ba_735e_a2e4_e60f625b4070["edit-in-v0.ts"] c4bb9c72_bb18_42a5_9e9a_4d568ef28d92 -->|defined in| cd9b6915_a6ba_735e_a2e4_e60f625b4070 style c4bb9c72_bb18_42a5_9e9a_4d568ef28d92 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
deprecated/www/actions/edit-in-v0.ts lines 11–108
export async function editInV0({
name,
style,
url,
}: {
name: string
style?: Style["name"]
url: string
}) {
style = style ?? "new-york"
try {
const registryItem = await getRegistryItem(name, style)
if (!registryItem) {
return { error: "Something went wrong. Please try again later." }
}
await track("edit_in_v0", {
name,
title: registryItem.name,
description: registryItem.description ?? registryItem.name,
style,
url,
})
// Remove v0 prefix from the name
registryItem.name = registryItem.name.replace(/^v0-/, "")
const projectName = capitalCase(name.replace(/\d+/g, ""))
registryItem.description = registryItem.description || projectName
// Replace `@/registry/new-york/` in files.
registryItem.files = registryItem.files?.map((file) => {
if (file.content?.includes("@/registry/new-york/ui")) {
file.content = file.content?.replaceAll(
"@/registry/new-york/ui",
"@/components/ui"
)
}
return file
})
if (TAILWIND_CONFIG_BLOCKS.includes(name)) {
registryItem.files?.push({
path: "tailwind.config.js",
type: "registry:file",
target: "tailwind.config.js",
content: TAILWIND_CONFIG,
})
}
const payload = {
version: 2,
payload: registryItem,
source: {
title: "shadcn/ui",
url,
},
meta: {
project: projectName,
file: `${name}.tsx`,
},
}
const response = await fetch(`${process.env.V0_URL}/chat/api/open-in-v0`, {
method: "POST",
body: JSON.stringify(payload),
headers: {
"x-v0-edit-secret": process.env.V0_EDIT_SECRET!,
"x-vercel-protection-bypass":
process.env.DEPLOYMENT_PROTECTION_BYPASS || "not-set",
"Content-Type": "application/json",
},
})
if (!response.ok) {
if (response.status === 403) {
throw new Error("Unauthorized")
}
console.error(response.statusText)
Domain
Subdomains
Defined In
Source
Frequently Asked Questions
What does editInV0() do?
editInV0() is a function in the ui codebase, defined in deprecated/www/actions/edit-in-v0.ts.
Where is editInV0() defined?
editInV0() is defined in deprecated/www/actions/edit-in-v0.ts at line 11.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free