Capítulo 106 de 108

Open in v0

Core Idea

Any publicly hosted registry item can be opened directly in v0 via https://v0.dev/chat/api/open?url=[URL], with a ready-made button component to drop into a registry's docs site.

Key Concepts

  • Open-in-v0 endpoint: https://v0.dev/chat/api/open?url=<item-json-url> loads that registry item's content into a new v0 chat.
  • Feature limitations: Does NOT support cssVars, css, envVars, namespaced registries, or advanced auth (Bearer/API-key headers).
  • Auth support: Only query-parameter tokens (?token=...); server validates and returns 401 on failure, same convention as the CLI.

Code Examples

export function OpenInV0Button({ url }: { url: string }) {
  return (
    <Button asChild>
      <a href={`https://v0.dev/chat/api/open?url=${url}`} target="_blank" rel="noreferrer">
        Open in v0
      </a>
    </Button>
  )
}
  • O que demonstra: componente mínimo de botão "Open in v0" apontando pro item JSON público.
https://registry.company.com/r/hello-world.json?token=your_secure_token_here
  • O que demonstra: única forma de auth suportada pelo Open in v0 (token via query string), diferente do leque completo (headers) que a CLI aceita.

Anti-patterns

  • Relying on cssVars/css/envVars showing up correctly via Open in v0: those fields are ignored by this integration; test the full CLI add flow separately.
  • Using Bearer/header auth expecting it to work with Open in v0: only query-param token is supported here.
  • Never expire tokens used in docs/examples: encrypt and expire tokens shown publicly.

Key Takeaways

  1. Open in v0 is a convenience shortcut, not a full CLI substitute — verify feature-complete behavior (CSS vars, env vars) through npx shadcn add instead.
  2. If a registry needs both v0 and CLI compatibility, layer query-param token auth (works for both) rather than headers-only auth (v0-incompatible).

Connects To

  • registry-authentication (ch102): full auth pattern set, of which only query-param auth is v0-compatible.
  • registry-item-json (ch108): fields (cssVars, css, envVars) that Open in v0 silently drops.