# Installation

> Connect a project to the shadcn/ui Pro registry so the shadcn CLI can install blocks with your license key.

## Before you start

You need a project with shadcn/ui set up, which means a `components.json` file at its root. If your project doesn't have one yet, run:

```bash
npx shadcn@latest init
```

You also need an active shadcn/ui Pro plan. To try the [free blocks](#free-blocks-without-a-license-key) first, you don't.

## Set up the registry

### Create a license key

Open [Account → License keys](https://pro.shadcn.co/account/license-keys) and click **New license key**. Name it after where you'll use it, such as "Work laptop" or "CI", so you can revoke it later without affecting anything else.

The key starts with `shadcnpro_` and is shown only once, so copy it before you close the dialog.

### Add the key to `.env.local`

In your project root, add the key to `.env.local`. Create the file if it doesn't exist.

```dotenv title=".env.local"
SHADCNPRO_LICENSE_KEY=YOUR_LICENSE_KEY
```

Keep `.env.local` out of git. Most project templates already ignore it.

### Add the registry to `components.json`

Add a `registries` entry to `components.json`, next to the settings that are already there:

```json title="components.json"
{
  "registries": {
    "@shadcnpro": {
      "url": "https://pro.shadcn.co/api/registry/{name}?style={style}",
      "headers": {
        "License-Key": "${SHADCNPRO_LICENSE_KEY}"
      }
    }
  }
}
```

Leave `{name}`, `{style}` and `${SHADCNPRO_LICENSE_KEY}` as they are. The CLI fills in the block name and your project's style, and reads the key from `.env.local` on every run, so the key never ends up in your code. The style tells the registry whether your project uses Radix UI, Base UI or React Aria, so you get the matching version of each block.

### Install a block

Blocks install from the `@shadcnpro` namespace:

```bash
npx shadcn@latest add @shadcnpro/pricing-01
```

The block lands in `components/blocks/pricing-01.tsx`, together with the shadcn/ui components it uses. Next, [use and customize it](https://pro.shadcn.co/docs/blocks#use-a-block).

## Check the setup

To check the registry without installing anything, print a block's details:

```bash
npx shadcn@latest view @shadcnpro/pricing-01
```

If you see the block as JSON, the setup works. If you see an error, find its message below.

| Error message | What to do |
|---|---|
| "Registry "@shadcnpro" requires the following environment variables" | `.env.local` doesn't define `SHADCNPRO_LICENSE_KEY`, or you ran the command outside the project root. |
| "This license key is invalid or has been revoked" | The key has a typo or was revoked. Copy it again, or create a new one. |
| "Your license key is valid but there is no active Pro subscription" | The plan on the key's account has ended, or you left the workspace that has the plan. Check [Account → Billing](https://pro.shadcn.co/account/billing). |
| "This is a Pro item. Add your license key" | `components.json` has no `headers` entry for `@shadcnpro`. Add it as shown above. |
| "Not found" | The block id is wrong. Copy the id from the block on the [Blocks](https://pro.shadcn.co/pro-blocks) page. |

If the [MCP server](https://pro.shadcn.co/docs/mcp/introduction) is connected, you can also ask your agent: "Use shadcnpro to check my components.json."

## Free blocks without a license key

62 blocks are free and install without a plan. If you only use free blocks, leave the license key out: skip the first two steps and register the registry without `headers`.

```json title="components.json"
{
  "registries": {
    "@shadcnpro": {
      "url": "https://pro.shadcn.co/api/registry/{name}?style={style}"
    }
  }
}
```

**Note:**
Keep `headers` out until you have a key. The CLI stops when `components.json` refers to `${SHADCNPRO_LICENSE_KEY}` and the variable isn't set, even for free blocks.

## Managing license keys

- **One key per place.** Create a key for each computer or pipeline, up to 10 per account. Revoking one doesn't affect the others.
- **Teams.** Everyone creates their own key in their own account. Commit `components.json` as shown above and let each person put their key in their own `.env.local`.
- **CI.** Add `SHADCNPRO_LICENSE_KEY` as a secret environment variable wherever the CLI runs. Your deployed app doesn't need the key: installed blocks are plain source code in your repository.
- **When a plan ends.** Keys stop working when the plan ends or you leave the workspace, and work again as soon as a plan is active. You don't need new keys.
- **Revoking.** Revoke a key in [Account → License keys](https://pro.shadcn.co/account/license-keys). It stops working within a minute.
- **Rate limit.** Each key can make 300 requests per minute, shared between the CLI and the MCP server.
