This guide will walk you through the process of setting up your own component registry. It assumes you already have a project with components and would like to turn it into a registry. If you’re starting a new registry project, you can use the registry template as a starting point. We have already configured it for you.Documentation Index
Fetch the complete documentation index at: https://mintlify.com/shadcn-ui/ui/llms.txt
Use this file to discover all available pages before exploring further.
Requirements
You are free to design and host your custom registry as you see fit. The only requirement is that your registry items must be valid JSON files that conform to the registry-item schema specification. If you’d like to see an example of a registry, we have a template project for you to use as a starting point.Overview
Theregistry.json is the entry point for the registry. It contains the registry’s name, homepage, and defines all the items present in the registry.
Your registry must have this file (or JSON payload) present at the root of the registry endpoint. The registry endpoint is the URL where your registry is hosted.
The shadcn CLI will automatically generate individual JSON files for each registry item when you run the build command.
Step-by-Step Setup
Add a registry.json file
Create a This
registry.json file in the root of your project. Your project can be a Next.js, Vite, Vue, Svelte, PHP or any other framework as long as it supports serving JSON over HTTP.registry.json
registry.json file must conform to the registry schema specification.Create your component
Add your first component. Here’s an example of a simple Your directory structure should look like this:
<HelloWorld /> component:registry/new-york/hello-world/hello-world.tsx
This example places the component in the
registry/new-york directory. You can place it anywhere in your project as long as you set the correct path in the registry.json file and follow the registry/[STYLE]/[NAME] directory structure.Add your component to the registry
To add your component to the registry, you need to add your component definition to You define your registry item by adding:
registry.json.registry.json
name- Unique identifier for the itemtype- The type of registry itemtitle- Human-readable titledescription- Brief description of the componentfiles- Array of files with their paths and types
path and type of the file. The path is the relative path to the file from the root of your project. The type is the type of the file.You can read more about the registry item schema and file types in the registry item schema docs.Run the build script
Run the build script to generate the registry JSON files:
By default, the build script will generate the registry JSON files in
public/r e.g public/r/hello-world.json.You can change the output directory by passing the --output option. See the shadcn build command for more information.Serve your registry
If you’re running your registry on Next.js, you can now serve your registry by running the development server. The command might differ for other frameworks.Your files will now be served at
http://localhost:3000/r/[NAME].json e.g. http://localhost:3000/r/hello-world.json.Adding Dependencies
Your components often depend on npm packages or other registry items. Here’s how to declare them:Best Practices
Here are some guidelines to follow when building components for a registry:Directory Structure
Directory Structure
Place your registry item in the
registry/[STYLE]/[NAME] directory. For example, use new-york as the style name. It can be anything you want as long as it’s nested under the registry directory.Required Properties
Required Properties
The following properties are required for any registry item:
name- Unique identifierdescription- Clear description for users and LLMstype- Registry item typefiles- Array of files with paths and types
Import Paths
Import Paths
Imports should always use the
@/registry path. This ensures consistency across projects:File Organization
File Organization
Ideally, place your files within a registry item in organized directories:
components/- React componentshooks/- Custom hookslib/- Utility functions and helperstypes/- TypeScript type definitions
Dependencies
Dependencies
- List all npm packages in
dependenciesordevDependencies - List all registry items in
registryDependencies - Use version specifiers when needed:
zod@^3.20.0 - Registry dependencies can be:
- Names:
"button","input" - Namespaced:
"@acme/input-form" - URLs:
"https://example.com/r/editor.json"
- Names:
Installing from Your Registry
Once your registry is published, users can install items using theshadcn CLI:
Using Direct URLs
Using Namespaces
Configure the registry incomponents.json:
components.json
Advanced Configuration
Adding CSS Variables
Include CSS variables that your component needs:registry-item.json
Adding Environment Variables
registry-item.json
Custom Installation Instructions
Provide additional documentation that shows after installation:registry-item.json
Next Steps
Registry Item Schema
Learn about all available properties and configurations for registry items.
Examples
Explore real-world examples of different registry item types.
Authentication
Secure your private registry with authentication.
Namespaces
Set up namespaced registries for better organization.