Skip to main content
The build command builds components for a shadcn/ui registry. Use it to create a custom registry by bundling your component files into registry JSON files.

Usage

Arguments

string
default:"./registry.json"
Path to the registry.json file. Defaults to ./registry.json in the current directory.

Options

string
default:"./public/r"
Destination directory for JSON files. Defaults to ./public/r.
string
The working directory. Defaults to the current directory.

Examples

Build with default paths

Builds from ./registry.json to ./public/r.

Build from custom registry file

Build to custom output directory

Build with custom paths

Build in specific directory

What it does

  1. Reads the registry.json file
  2. Validates the registry schema
  3. For each registry item:
    • Reads the source files from disk
    • Embeds file content into the registry item
    • Adds the JSON schema URL
    • Validates the complete registry item
    • Writes a JSON file to the output directory
  4. Copies registry.json to the output directory

Registry structure

Your registry.json should follow this structure:

Output structure

After building, your output directory will contain:
Each component JSON file includes the source code:

Registry item fields

Each item in registry.json can include:
string
required
Unique identifier for the component.
string
required
Registry type: registry:ui, registry:block, registry:hook, registry:lib, etc.
array
required
Array of file objects with path and optional type.
array
npm packages required by the component.
array
npm dev packages required by the component.
array
Other registry components required by this component.
object
Additional metadata (description, tags, etc.).

Creating a custom registry

1. Create registry.json

2. Build the registry

3. Serve the registry

Deploy the public/r directory to a web server or CDN.

4. Use the registry

Add to components.json:
Install components:

Validation

The build command validates:
  1. Registry schema - Ensures registry.json is valid
  2. Registry item schema - Validates each component’s metadata
  3. File existence - Checks that all referenced files exist
If validation fails, the build will:
  • Log an error message
  • Skip the invalid item
  • Continue building other items

Use cases

Internal component library

Build a private registry for your organization:

Open source components

Share your components publicly:

Monorepo packages

Build registries for multiple packages:

Output

Error handling

Invalid registry file

Solution: Validate your JSON syntax and schema.

Invalid registry item

Solution: Check that all required fields are present and valid.

File not found

If a referenced file doesn’t exist, the build will fail. Ensure all paths in files arrays are correct and relative to the cwd.

Notes

  • File paths in registry.json should be relative to the working directory
  • The build embeds full file content, so output files can be large
  • Output is production-ready JSON for hosting
  • Schema URLs are automatically added to built files
  • Original registry.json is copied to output directory
  • Safe to run multiple times (overwrites previous build)