Skip to content

Install components from a shadcn registry (npx shadcn add @namespace)

Install by URL with no setup, or name a registry in components.json and install by namespace. Private registries read their key from .env.local.

Updated 23 November 2026Tested with
  • shadcn 4.23.0
  • www.themes.dev registry

A shadcn registry is a server that hands out components as JSON. The CLI can install from any of them: either by full URL (npx shadcn@latest add https://example.com/r/pricing.json) or, once you've named the registry in components.json, by namespace (npx shadcn@latest add @acme/pricing). Private registries send a key in a header, read from an environment variable so it never lands in your repo.

We use our own registry, @themesdev, as the example, because we could test every step against it. The setup is the same for any other.

Install by URL: no setup

Any item that's public installs straight from its URL. This is our free pricing block:

npx shadcn@latest add https://www.themes.dev/r/ui/pricing.json

The CLI reads the JSON, writes the block's file, adds the shadcn primitives it lists (in our test: badge, separator and tabs) and installs npm packages it needs. If a file already exists, it asks before overwriting.

Add a registry by namespace

Typing URLs gets old. Add the registry to components.json once and use short names after that. Each entry maps a namespace to a URL template, where {name} is replaced by the item name:

components.jsonJSON
{  "registries": {    "@themesdev": {      "url": "https://www.themes.dev/r/ui/{name}.json",      "headers": { "Authorization": "Bearer ${THEMESDEV_TOKEN}" }    }  }}

Keep the rest of the file as it is; registries sits next to aliases and tailwind. You can also let the CLI write it: npx shadcn@latest registry add @themesdev=https://www.themes.dev/r/ui/{name}.json, which writes the short form ("@themesdev": "https://…/{name}.json"). For a key you need the object form above, so change it by hand.

Now these work:

Terminal
npx shadcn@latest search @themesdev -q pricingFound 9 items matching "pricing" in @themesdev- @themesdev/pricing (block) — Three plan cards under a monthly/yearly switch…npx shadcn@latest view @themesdev/pricingnpx shadcn@latest add @themesdev/pricing

A registry listed in shadcn's official directory works by namespace without any config, the same way @shadcn does.

Private items: the key in an environment variable

${THEMESDEV_TOKEN} in components.json is expanded by the CLI from your environment. It also reads .env and .env.local in the project, which we checked: with the key only in .env.local, the install went through.

.env.localShell
THEMESDEV_TOKEN=tdk_…

Add .env.local to .gitignore if it isn't already (Vite and Next.js projects ignore it by default). In CI, set the variable in the runner's secrets instead.

One thing that catches people out: once the entry has headers, the CLI refuses every command for that namespace while the variable is unset, even for public items:

Terminal
npx shadcn@latest add @themesdev/hero-12Registry "@themesdev" requires the following environment variables:  • THEMESDEV_TOKENSuggestion:Set the required environment variables to your .env or .env.local file.

Public items still install by full URL without a key.

When the server says no

A good registry tells you why. Asking ours for a UI Pro block with an invalid key:

Terminal
npx shadcn@latest add @themesdev/hero-03Error:You are not authorized to access the item at https://www.themes.dev/r/ui/hero-03.json. If this is a remote registry, you may need to authenticate.Message:[Unauthorized] This is a UI Pro item. With a UI Pro license, make an API key at https://www.themes.dev/account/ and set THEMESDEV_TOKEN to it.

The first part is the CLI's generic text for a 401; the line after Message: comes from the registry. If you get a 401 with a key you're sure is right, check that the variable name in components.json matches the one in your env file exactly, and that the key has no quotes or trailing space around it.

Where the files go

The item decides its target. Primitives (registry:ui) go to the ui alias, usually src/components/ui. Blocks go where the registry says: our blocks land in components/<category>/, for example src/components/heroes/hero-hallway.tsx. Run with --dry-run first to see the paths without writing anything, and --path to put a single item somewhere else.

Questions

Is a shadcn registry the same as npm?

No. npm installs a package into node_modules that you import and update as a version. A registry copies source files into your project; after that, they're yours. The CLI does install npm packages that an item depends on.

Can I use several registries in one project?

Yes. Add as many namespaces as you like under registries. An item from one registry can depend on items from another; the CLI resolves them all.

How do I build my own registry?

Write a registry.json listing your items and run npx shadcn@latest build to produce the JSON files, then host them anywhere static. We'll cover it in its own article; until then the shadcn docs' registry section is the reference.

Was this page helpful?

Still stuck? We answer every message ourselves. Write to us

This page is built from UI Pro parts: the docs article block (docs-quernly) with the code, terminal, install command, steps, contents and feedback components. They ship in the next UI Pro release; the install command and the contents rail are free.