Registries

Learn how registries map URL schemes to template locations.

A registry maps URL schemes to template locations using pattern matching. The CLI includes a built-in registry with schemes for popular component libraries and the Croct template catalog.

Format

A registry is a JSON5 array of objects, each with a pattern and a destination:

registry.json5
[  {    "pattern": "^croct://?(.+)$",    "destination": "croct/$1"  },  {    "pattern": "^shadcn-ui://?(.+)$",    "destination": "shadcn-ui/$1"  }]

Properties

Each entry in the registry array has the following properties:

pattern
string

A regular expression matched against the source URL.

Use capture groups to extract parts of the URL for use in the destination.

destination
string

The resolved path for matching sources.

Use $1, $2, etc. to reference capture groups from the pattern. Destinations are resolved relative to the registry file location.

Built-in schemes

The built-in registry provides the following schemes:

SchemeDescription
croct://Croct templates
shadcn-ui://shadcn/ui components
magic-ui://Magic UI components
hero-ui://Hero UI components
material-ui://Material UI components
mantine://Mantine components
tailwind://Tailwind utilities
nextjs://Next.js templates
npm://npm packages

For example, croct://starter/nextjs matches the pattern ^croct://?(.+)$ and resolves to the path croct/starter/nextjs relative to the registry file.

Resolution

Patterns are matched in order, and the first match wins. Destinations are resolved relative to the registry file location, so a registry hosted on GitHub will resolve paths to files in the same repository.

Custom registries

To use your own registry, pass the --registry global option:

npx croct@latest --registry https://example.com/registry.json5 use my-scheme://template

This tells the CLI to load your registry file instead of the built-in one.

For details on contributing new schemes to the built-in registry, see the publishing templates tutorial.