docs(www): add auth section for registry (#6910)

This commit is contained in:
shadcn
2025-03-12 18:33:36 +04:00
committed by GitHub
parent d999f803a8
commit 79f2498b28
2 changed files with 23 additions and 6 deletions

View File

@@ -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.
<Callout className="mt-6">
**Note:** Make sure to encrypt and expire tokens.
</Callout>
## Guidelines
Here are some guidelines to follow when building components for a registry.

View File

@@ -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)
<Callout className="mt-6">
**Note:** The `Open in v0` button does not support `cssVars` and `tailwind`
properties.
</Callout>
## 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
<OpenInV0Button url="https://example.com/r/hello-world.json" />
```
## 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.