A production-ready template for building your own component registry with shadcn/ui compatibility and custom CLI tooling.
This starter kit provides everything you need to create, maintain, and distribute a component registry similar to shadcn/ui. Built with modern tooling and best practices, it enables developers to build their own design systems with seamless CLI integration.
- Zero-config setup: Get a fully functional registry in minutes
- shadcn/ui compatibility: Leverage the existing ecosystem and tooling
- Automated workflows: Component discovery, registry generation, and publishing
- Professional documentation: Built-in docs site with live examples
- CLI distribution: Publish your own
npx your-registry add componentCLI
- Consistent design system: Maintain design consistency across projects
- Easy adoption: Developers can add components with a single command
- Version control: Track component changes and updates
- Customization: Full control over component implementations
This monorepo is built with Turborepo and follows a modular architecture:
devcn-ui/
βββ apps/
β βββ docs/ # Next.js documentation site
β βββ app/ # App router pages
β βββ content/ # MDX documentation
β βββ public/registry/ # Generated component registry
βββ packages/
β βββ ai/ # AI-specific components
β βββ code-block/ # Code display components
β βββ editor/ # Editor components
β βββ shadcn-ui/ # Base shadcn/ui components
β βββ snippet/ # Code snippet components
β βββ ui/ # Custom UI components
βββ scripts/
β βββ index.ts # CLI entry point
β βββ generate-registry.js # Registry generation
β βββ discover-components.js # Component discovery
β βββ register-all-components.js # Batch registration
βββ dist/
βββ index.js # Built CLI executable
- π¦ Component Packages: Modular packages containing reusable components
- π οΈ CLI Tool: Custom CLI for installing components (
npx your-registry add component) - π Documentation Site: Next.js app with live examples and installation guides
- π€ Automation Scripts: Tools for component discovery and registry generation
- π Registry System: JSON-based component metadata and file definitions
- Node.js 18+ and pnpm (recommended)
- Git for version control
- GitHub account for repository hosting
# Clone the repository
git clone https://github.com/your-username/devcn-ui.git
cd devcn-ui
# Install dependencies
pnpm install
# Start development server
pnpm devThe documentation site will be available at http://localhost:3422
Edit package.json to reflect your registry:
{
"name": "your-registry-name",
"description": "Your custom component registry",
"homepage": "https://your-registry.com",
"repository": {
"type": "git",
"url": "https://github.com/your-username/your-registry.git"
},
"bin": {
"your-cli": "dist/index.js"
}
}Modify scripts/index.ts to customize your CLI:
// Update the registry URL
const url = new URL(
`registry/${packageName}.json`,
'https://your-registry.com/' // Your registry URL
);Create a new package in packages/:
mkdir packages/your-component
cd packages/your-componentCreate the component structure:
packages/your-component/
βββ package.json
βββ src/
β βββ index.tsx
βββ README.md
package.json:
{
"name": "@repo/your-component",
"version": "0.0.1",
"private": true,
"main": "src/index.tsx",
"types": "src/index.tsx"
}src/index.tsx:
import React from 'react';
import { cn } from '@/lib/utils';
export interface YourComponentProps {
className?: string;
children?: React.ReactNode;
}
export const YourComponent = ({ className, children, ...props }: YourComponentProps) => {
return (
<div className={cn('your-component-styles', className)} {...props}>
{children}
</div>
);
};
export default YourComponent;This starter kit includes an automated registry generation system that scans your components and builds the complete registry with a single command.
Quick Start - Build Complete Registry:
# Generate and build the complete registry in one command
pnpm run registryThis command will:
- Scan all packages for component files
- Generate the
registry.jsonfile with proper shadcn/ui schema - Build individual component JSON files in
public/r/ - Make your registry ready for CLI consumption
For more granular control, you can run each step separately:
# 1. Generate the registry.json file by scanning packages
pnpm run gen:registry
# 2. Build the registry (creates individual JSON files)
pnpm run build:registryThe automated system:
- Scans
packages/directory: Automatically discovers all TypeScript/TSX component files - Excludes config packages: Ignores
eslint-config,typescript-config, andshadcn-uipackages - Handles AI components: Special logic for the
aipackage to create individual registry entries - Generates descriptions: Maps component names to meaningful descriptions
- Creates proper schema: Follows the official shadcn/ui registry format
When you add new components:
- Create your component in the appropriate
packages/directory - Run
pnpm run registryto regenerate the complete registry - Your new component will be automatically discovered and included
The automated process creates:
registry.json- Main registry file with all component metadatapublic/r/[component].json- Individual component files for CLI consumption
Each component generates a registry file like this:
{
"name": "your-component",
"description": "A custom component for your design system",
"dependencies": ["@radix-ui/react-slot"],
"devDependencies": ["@types/react"],
"registryDependencies": ["utils"],
"files": [
{
"name": "your-component.tsx",
"content": "...component source code..."
}
],
"type": "components:ui"
}The scripts/generateRegistry.ts file is the heart of the automated registry system. Here's how it works:
- Automatic Package Discovery: Scans the
packages/directory for all subdirectories - Component File Detection: Identifies
.tsand.tsxfiles while excluding test files - Smart AI Component Handling: Creates individual registry entries for each file in the
aipackage - Description Mapping: Uses a predefined dictionary to provide meaningful component descriptions
- Proper Schema Generation: Creates registry files that comply with shadcn/ui standards
To customize the registry generation for your needs:
- Update Component Descriptions: Edit the
COMPONENT_DESCRIPTIONSobject inscripts/generateRegistry.ts:
const COMPONENT_DESCRIPTIONS: Record<string, string> = {
'your-component': 'Description of your component',
'another-component': 'Another component description',
// Add your components here
};- Modify Package Exclusions: Update the
excludedPackagesarray:
const excludedPackages = ['eslint-config', 'typescript-config', 'your-excluded-package'];- Change Registry Metadata: Update the registry object properties:
const registry: Registry = {
$schema: 'https://ui.shadcn.com/schema/registry.json',
name: 'your-registry-name',
homepage: 'https://your-registry-homepage.com',
items: allItems
};When you run pnpm run gen:registry, you'll see output like:
π Scanning packages directory...
π¦ Processing package: ai
π¦ Processing package: code-block
π¦ Processing package: editor
β
Registry generated successfully!
π Generated 14 component(s):
- ai-branch: AI conversation branch component
- code-block: Enhanced code block component
- editor: Code editor component
πΎ Registry saved to: registry.json
# Build the CLI
pnpm build:cli
# Test the CLI locally
pnpm test:cliEnsure your registry is complete:
# Generate and build the complete registry
pnpm run registry
# Build the CLI
pnpm run build:cli
# Build the documentation site
pnpm run build# Patch version (bug fixes)
pnpm publish:patch
# Minor version (new features)
pnpm publish:minor
# Major version (breaking changes)
pnpm publish:majorDeploy your docs site to Vercel, Netlify, or your preferred platform:
# For Vercel
vercel --prod
# For Netlify
netlify deploy --prod --dir=apps/docs/outOnce published, users can install components from your registry:
# Install your CLI globally or use with npx
npx your-registry-name add button card dialog
# Or install globally
npm install -g your-registry-name
your-registry-name add button# Start development server
pnpm dev
# Add new components to packages/
# Regenerate the complete registry
pnpm run registry
# Test CLI locally
pnpm run test:cli# Lint code
pnpm lint
# Format code
pnpm format
# Type checking
pnpm build
# Validate registry
pnpm validate:registry- Update components and test locally
- Run full discovery and registration:
pnpm discover:components pnpm register:all pnpm generate:registry
- Build and test CLI:
pnpm build:cli pnpm test:cli
- Commit changes and create release
- Publish to npm:
pnpm publish:minor # or patch/major - Deploy documentation to your hosting platform
| Script | Description |
|---|---|
pnpm dev |
Start development server |
pnpm build |
Build all packages and apps |
pnpm build:cli |
Build CLI executable |
pnpm test:cli |
Test CLI locally |
pnpm run gen:registry |
Generate registry.json by scanning packages |
pnpm run build:registry |
Build individual component JSON files |
pnpm run registry |
Complete registry generation and build |
pnpm publish:patch/minor/major |
Version bump and publish |
pnpm lint |
Lint codebase |
pnpm format |
Format code |
pnpm clean |
Clean node_modules and build artifacts |
pnpm bump-deps |
Update all dependencies |
pnpm bump-ui |
Update shadcn/ui components |
- Follow shadcn/ui patterns for consistency
- Use TypeScript for type safety
- Include proper prop interfaces and documentation
- Add examples in your documentation
- Test components thoroughly before publishing
- Run
pnpm run registryafter adding new components to regenerate the complete registry - Update component descriptions in
scripts/generateRegistry.tsfor new components - Test the CLI with
pnpm run test:clibefore publishing - Version components appropriately using semantic versioning
- Document breaking changes in release notes
- Test CLI locally before publishing
- Follow semantic versioning for releases
- Provide clear error messages for users
- Include helpful documentation and examples
Contributions are welcome! Please read our contributing guidelines and submit pull requests for any improvements.
- Fork the repository
- Clone your fork:
git clone https://github.com/your-username/devcn-ui.git - Install dependencies:
pnpm install - Create a feature branch:
git checkout -b feature/amazing-feature - Make your changes and test thoroughly
- Submit a pull request
This project is licensed under the MIT License. See the LICENSE file for details.
- shadcn/ui - Original inspiration and compatibility target
- Turborepo - Monorepo build system
- Next.js - Documentation framework
- Tailwind CSS - Styling framework
- Radix UI - Primitive components
Ready to build your own component registry? π
Start by cloning this repository and following the setup instructions above. Within minutes, you'll have a fully functional component registry with CLI distribution capabilities!