|
| 1 | +--- |
| 2 | +title: May 2026 - Registry Include and Validate |
| 3 | +description: Organize and validate source registries. |
| 4 | +date: 2026-05-20 |
| 5 | +--- |
| 6 | + |
| 7 | +This release adds two updates for registry authors: |
| 8 | + |
| 9 | +- `include` for composing large source registries from multiple `registry.json` |
| 10 | + files. |
| 11 | +- `shadcn registry validate` for checking source registries before publishing. |
| 12 | + |
| 13 | +This makes it easier to maintain source and dynamic registries without keeping |
| 14 | +one large `registry.json` file by hand. |
| 15 | + |
| 16 | +Registry authors can now organize a large source registry across multiple |
| 17 | +`registry.json` files and compose them with `shadcn build`. |
| 18 | + |
| 19 | +```txt /registry.json/ |
| 20 | +registry.json |
| 21 | +components |
| 22 | +└── ui |
| 23 | + ├── button.tsx |
| 24 | + ├── input.tsx |
| 25 | + └── registry.json |
| 26 | +hooks |
| 27 | +├── registry.json |
| 28 | +├── use-media-query.ts |
| 29 | +└── use-toggle.ts |
| 30 | +``` |
| 31 | + |
| 32 | +{/* prettier-ignore */} |
| 33 | +```json title="registry.json" showLineNumbers {6-7} |
| 34 | +{ |
| 35 | + "$schema": "https://ui.shadcn.com/schema/registry.json", |
| 36 | + "name": "acme", |
| 37 | + "homepage": "https://acme.com", |
| 38 | + "include": [ |
| 39 | + "components/ui/registry.json", |
| 40 | + "hooks/registry.json" |
| 41 | + ] |
| 42 | +} |
| 43 | +``` |
| 44 | + |
| 45 | +Included `registry.json` files are valid registry files for composition and may |
| 46 | +omit `name` and `homepage`. Only the root `registry.json` must define the |
| 47 | +registry metadata. |
| 48 | + |
| 49 | +```json title="components/ui/registry.json" showLineNumbers |
| 50 | +{ |
| 51 | + "$schema": "https://ui.shadcn.com/schema/registry.json", |
| 52 | + "items": [ |
| 53 | + { |
| 54 | + "name": "button", |
| 55 | + "type": "registry:ui", |
| 56 | + "files": [ |
| 57 | + { |
| 58 | + "path": "button.tsx", |
| 59 | + "type": "registry:ui" |
| 60 | + } |
| 61 | + ] |
| 62 | + } |
| 63 | + ] |
| 64 | +} |
| 65 | +``` |
| 66 | + |
| 67 | +## Build output |
| 68 | + |
| 69 | +`shadcn build` resolves included registries and writes a flattened |
| 70 | +`registry.json` without `include`. Item file paths are preserved from the root |
| 71 | +registry, so a file declared in `components/ui/registry.json` is written as |
| 72 | +`components/ui/button.tsx` in the built registry item. |
| 73 | + |
| 74 | +## Validate your registry |
| 75 | + |
| 76 | +You can now validate a source registry before publishing or serving it. |
| 77 | + |
| 78 | +```bash |
| 79 | +npx shadcn registry validate |
| 80 | +``` |
| 81 | + |
| 82 | +Validation runs against the source registry files directly. You do not need to |
| 83 | +run `shadcn build` first. |
| 84 | + |
| 85 | +The command checks the root `registry.json`, included registry files, item |
| 86 | +schema errors, duplicate item names, include rules, and local item file paths. |
| 87 | +Validation reports all actionable errors it can find in one run. |
| 88 | + |
| 89 | +## Registry loaders |
| 90 | + |
| 91 | +The `shadcn/registry` package also exports `loadRegistry` and |
| 92 | +`loadRegistryItem` for dynamic registry routes. |
| 93 | + |
| 94 | +```ts title="app/r/registry.json/route.ts" showLineNumbers |
| 95 | +import { loadRegistry } from "shadcn/registry" |
| 96 | + |
| 97 | +export async function GET() { |
| 98 | + const registry = await loadRegistry() |
| 99 | + |
| 100 | + return Response.json(registry) |
| 101 | +} |
| 102 | +``` |
| 103 | + |
| 104 | +```ts title="app/r/[name].json/route.ts" showLineNumbers |
| 105 | +import { loadRegistryItem } from "shadcn/registry" |
| 106 | + |
| 107 | +export async function GET( |
| 108 | + _: Request, |
| 109 | + { params }: { params: Promise<{ name: string }> } |
| 110 | +) { |
| 111 | + const { name } = await params |
| 112 | + const item = await loadRegistryItem(name) |
| 113 | + |
| 114 | + return Response.json(item) |
| 115 | +} |
| 116 | +``` |
| 117 | + |
| 118 | +See the [registry.json documentation](/docs/registry/registry-json#include) and |
| 119 | +[getting started guide](/docs/registry/getting-started#structure-your-registry) |
| 120 | +for more details. |
0 commit comments