From 79f2498b28f53a74b8f43bcb39a0abdc2da7f286 Mon Sep 17 00:00:00 2001 From: shadcn Date: Wed, 12 Mar 2025 18:33:36 +0400 Subject: [PATCH] docs(www): add auth section for registry (#6910) --- .../content/docs/registry/getting-started.mdx | 12 ++++++++++++ apps/www/content/docs/registry/open-in-v0.mdx | 17 +++++++++++------ 2 files changed, 23 insertions(+), 6 deletions(-) diff --git a/apps/www/content/docs/registry/getting-started.mdx b/apps/www/content/docs/registry/getting-started.mdx index ac2b764802..3834390fc8 100644 --- a/apps/www/content/docs/registry/getting-started.mdx +++ b/apps/www/content/docs/registry/getting-started.mdx @@ -169,6 +169,18 @@ Your files will now be served at `http://localhost:3000/r/[NAME].json` eg. `http To make your registry available to other developers, you can publish it by deploying your project to a public URL. +## Adding Auth + +The `shadcn` CLI does not offer a built-in way to add auth to your registry. We recommend handling authorization on your registry server. + +A common simple approach is to use a `token` query parameter to authenticate requests to your registry. e.g. `http://localhost:3000/r/hello-world.json?token=[SECURE_TOKEN_HERE]`. + +Use the secure token to authenticate requests and return a 401 Unauthorized response if the token is invalid. Both the `shadcn` CLI and `Open in v0` will handle the 401 response and display a message to the user. + + + **Note:** Make sure to encrypt and expire tokens. + + ## Guidelines Here are some guidelines to follow when building components for a registry. diff --git a/apps/www/content/docs/registry/open-in-v0.mdx b/apps/www/content/docs/registry/open-in-v0.mdx index 4b4fab7862..3feda2ee71 100644 --- a/apps/www/content/docs/registry/open-in-v0.mdx +++ b/apps/www/content/docs/registry/open-in-v0.mdx @@ -5,11 +5,18 @@ description: Integrate your registry with Open in v0. If your registry is hosted and publicly accessible via a URL, you can open a registry item in v0 by using the `https://v0.dev/chat/api/open?url=[URL]` endpoint. -eg. [https://v0.dev/chat/api/open?url=https://example.com/r/hello-world.json](https://v0.dev/chat/api/open?url=https://example.com/r/hello-world.json) +eg. [https://v0.dev/chat/api/open?url=https://ui.shadcn.com/r/styles/new-york/login-01.json](https://v0.dev/chat/api/open?url=https://ui.shadcn.com/r/styles/new-york/login-01.json) + + + **Note:** The `Open in v0` button does not support `cssVars` and `tailwind` + properties. + ## Button -You can copy and paste the following code to add a `Open in v0` button to your site. +See [Build your Open in v0 button](https://v0.dev/chat/button) for more information on how to build your own `Open in v0` button. + +Here's a simple example of how to add a `Open in v0` button to your site. ```jsx import { Button } from "@/components/ui/button" @@ -48,12 +55,10 @@ export function OpenInV0Button({ url }: { url: string }) { } ``` -## Usage - ```jsx ``` -## Known issues +## Authentication -- The `Open in v0` button does not support `cssVars` and `tailwind` properties. +See the [Adding Auth](/docs/registry/getting-started#adding-auth) section for more information on how to authenticate requests to your registry and Open in v0.