121 lines
3.1 KiB
Plaintext
121 lines
3.1 KiB
Plaintext
---
|
|
title: May 2026 - Registry Include and Validate
|
|
description: Organize and validate source registries.
|
|
date: 2026-05-20
|
|
---
|
|
|
|
This release adds two updates for registry authors:
|
|
|
|
- `include` for composing large source registries from multiple `registry.json`
|
|
files.
|
|
- `shadcn registry validate` for checking source registries before publishing.
|
|
|
|
This makes it easier to maintain source and dynamic registries without keeping
|
|
one large `registry.json` file by hand.
|
|
|
|
Registry authors can now organize a large source registry across multiple
|
|
`registry.json` files and compose them with `shadcn build`.
|
|
|
|
```txt /registry.json/
|
|
registry.json
|
|
components
|
|
└── ui
|
|
├── button.tsx
|
|
├── input.tsx
|
|
└── registry.json
|
|
hooks
|
|
├── registry.json
|
|
├── use-media-query.ts
|
|
└── use-toggle.ts
|
|
```
|
|
|
|
{/* prettier-ignore */}
|
|
```json title="registry.json" showLineNumbers {6-7}
|
|
{
|
|
"$schema": "https://ui.shadcn.com/schema/registry.json",
|
|
"name": "acme",
|
|
"homepage": "https://acme.com",
|
|
"include": [
|
|
"components/ui/registry.json",
|
|
"hooks/registry.json"
|
|
]
|
|
}
|
|
```
|
|
|
|
Included `registry.json` files are valid registry files for composition and may
|
|
omit `name` and `homepage`. Only the root `registry.json` must define the
|
|
registry metadata.
|
|
|
|
```json title="components/ui/registry.json" showLineNumbers
|
|
{
|
|
"$schema": "https://ui.shadcn.com/schema/registry.json",
|
|
"items": [
|
|
{
|
|
"name": "button",
|
|
"type": "registry:ui",
|
|
"files": [
|
|
{
|
|
"path": "button.tsx",
|
|
"type": "registry:ui"
|
|
}
|
|
]
|
|
}
|
|
]
|
|
}
|
|
```
|
|
|
|
## Build output
|
|
|
|
`shadcn build` resolves included registries and writes a flattened
|
|
`registry.json` without `include`. Item file paths are preserved from the root
|
|
registry, so a file declared in `components/ui/registry.json` is written as
|
|
`components/ui/button.tsx` in the built registry item.
|
|
|
|
## Validate your registry
|
|
|
|
You can now validate a source registry before publishing or serving it.
|
|
|
|
```bash
|
|
npx shadcn registry validate
|
|
```
|
|
|
|
Validation runs against the source registry files directly. You do not need to
|
|
run `shadcn build` first.
|
|
|
|
The command checks the root `registry.json`, included registry files, item
|
|
schema errors, duplicate item names, include rules, and local item file paths.
|
|
Validation reports all actionable errors it can find in one run.
|
|
|
|
## Registry loaders
|
|
|
|
The `shadcn/registry` package also exports `loadRegistry` and
|
|
`loadRegistryItem` for dynamic registry routes.
|
|
|
|
```ts title="app/r/registry.json/route.ts" showLineNumbers
|
|
import { loadRegistry } from "shadcn/registry"
|
|
|
|
export async function GET() {
|
|
const registry = await loadRegistry()
|
|
|
|
return Response.json(registry)
|
|
}
|
|
```
|
|
|
|
```ts title="app/r/[name].json/route.ts" showLineNumbers
|
|
import { loadRegistryItem } from "shadcn/registry"
|
|
|
|
export async function GET(
|
|
_: Request,
|
|
{ params }: { params: Promise<{ name: string }> }
|
|
) {
|
|
const { name } = await params
|
|
const item = await loadRegistryItem(name)
|
|
|
|
return Response.json(item)
|
|
}
|
|
```
|
|
|
|
See the [registry.json documentation](/docs/registry/registry-json#include) and
|
|
[getting started guide](/docs/registry/getting-started#structure-your-registry)
|
|
for more details.
|