> ## Documentation Index
> Fetch the complete documentation index at: https://help.21st.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Publish & manage

> Publish components, themes, and templates from the terminal, then edit or unpublish them.

> [!WARNING]
>
> Component publishing and metadata management accept a `21st login` session or
> a secret API key (`21st_sk_…`). Theme/template publishing, editing, and
> deleting still require an API key from [Settings → API
> keys](https://21st.dev/settings/api-keys), passed with `--api-key` or
> `API_KEY_21ST`.

## Find or resume component work

```bash theme={null}
21st components
21st components --status draft --scope personal --json
21st open component:123
21st open draft:550e8400-e29b-41d4-a716-446655440000 --no-open
```

`21st components` lists every accessible personal or Team component and every
owned saved draft, draining all result pages by default. It closes with how
many new drafts you may still start this hour, so the limit is visible before a
publish runs into it. Drafts nobody returns to are reclaimed automatically
after a day of silence. Use
`--status all|draft|published|private` and
`--scope all|personal|team:<uuid>` to narrow the inventory. The returned
`component:<id>` and `draft:<uuid>` values are stable references.

`21st open draft:<uuid>` resumes an editable Studio draft.
`21st open component:<id>` creates or resumes a server-owned CLI Review
revision from the retained published component code and demos. The live
component stays unchanged until that revision is published. Each demo needs a
fresh cover; Studio prioritizes the required covers and attempts optional
videos best-effort in the background. `--no-open` creates or resumes the
workspace and prints its editor URL without launching a browser.

Use a local file when you already changed the source:

```bash theme={null}
21st publish ./Component.tsx --component component:123 --description "What changed"
```

The ref prevents a same-slug component from being selected accidentally.
Only the original component author can check out its code. A Team manager can
still edit or unpublish a teammate's component metadata by its exact stable
ref.

Checkout fails closed if retained source, dependencies, style, support files,
or the default demo cannot be reproduced safely. In that case, use the local
source command above to create the reviewed revision.

A login session includes personal work and Teams the user can manage. A
personal key is personal-only; a Team key is restricted to that Team.

New CLI Review drafts persist their authenticated personal or Team/library
scope, so Team filters and Team keys can resume them. Legacy proof-backed CLI
drafts are recovered into the matching authenticated scope. An older unsigned
draft whose scope cannot be proven may need to be recreated.

## Look at a component without publishing it

```bash theme={null}
21st render ./Component.tsx --demo ./Component.demo.tsx --out ./preview
21st render ./Component.tsx --video --json
```

`21st render` builds the component in a Studio workspace, photographs its demo,
writes `default.png` (and `default.mp4` with `--video`) into `--out`, then
deletes the workspace — including on Ctrl-C. Nothing is published, nothing is
listed, and no draft is left behind for you to find later. Use it to check a
change before spending a publish on it.

It borrows one Studio workspace while it runs, so it counts against the same
draft limit as publishing; `--keep` leaves the workspace in place if you want
to open it in Studio afterwards.

## Manage a library

```bash theme={null}
21st library
21st library show sophon
21st library create design-system --name "Design System"
21st library update sophon --logo ./logo.svg --display-name "Sophon" --public
```

`21st library` lists every library you can manage — your own and those of
teams where you are an owner or admin. `update` changes only what you pass:
`--name`, `--description`, `--display-name`, `--logo <file>` or
`--logo-url <url>`, `--website`, `--github`, `--x`, and `--public` /
`--private` for the library's public page. A library whose access is private
has no public page, so `--public` is refused until the library itself is made
public in Studio. Logos accept PNG, JPEG, WebP or SVG up to 2 MiB. Add `--json`
to any of them for machine-readable output.

## Publish a component

```bash theme={null}
21st publish ./Component.tsx --description "A responsive pricing table"
```

The CLI auto-detects the component name, slug, and tags from the source, and
finds or synthesizes a demo file. A new slug or owned revision is
dependency-checked, installed, and built before its draft opens in the
dedicated **CLI Review**. Studio then generates the required cover and attempts
an optional video in the background; publishing stays locked until every demo
has a cover, but never waits for video. A cover you attach with
`--preview` satisfies that on its own — it becomes the demo's cover and no
generated one is required.

CLI Review is an overview: the component, its demos and their media, and the
tags each state their status, with the matching form one click behind them.
Above the preview, a switcher flips between the live demo, the captured cover,
the video, and the component's card as it appears in a listing. Access lives on
the same screen — Public or Private, plus whether to submit the component to
the catalog — so `--visibility` only sets the default. Publishing lands on the
published component.

Along with the Studio URL the CLI prints a **review link**. It opens the same
screen in a browser that is signed into nothing — an agent's browser, a phone,
a colleague's laptop — because it carries its own one-draft capability instead
of relying on a session. The link opens once, expires in 24 hours, and dies the
moment the draft is published or deleted; it can do nothing outside that draft.
Treat it like the draft itself: whoever holds it can finish this publish.

To update local source, pass its stable `--component component:<id>` ref; this
creates a pending revision and sends it through the same CLI Review instead of
updating the live component directly.

Agents and scripts can complete the same review without opening Studio:

```bash theme={null}
# Generate both assets, download them for inspection, and keep the draft.
21st publish ./Component.tsx \
  --description "A responsive pricing table" \
  --prepare --wait-video --media-dir .21st-review

# After inspection, publish that exact source revision.
21st publish ./Component.tsx \
  --description "A responsive pricing table" \
  --draft draft:<uuid> --auto --wait-video
```

`--prepare` never publishes. It waits for revision-bound automatic media and
optionally downloads it with `--media-dir`. `--auto` publishes only after every
required cover is ready; a cover attached with `--preview` counts as ready on
its own, so `--auto --preview` neither waits for nor fails on capture.
`--wait-video` additionally requires a successful video. Both modes are
CLI-only and never open a browser.

### One draft, many edits

`--draft` sends the file you pass into that draft before anything else, so
fixing the component and running the command again keeps working in the same
draft instead of creating a sandbox per edit:

```bash theme={null}
# Fix Component.tsx, then push it into the draft you already have.
21st publish ./Component.tsx \
  --description "A responsive pricing table" \
  --draft draft:<uuid> --prepare
```

The draft re-signs its revision and captures the cover and video again, exactly
as an edit made in the review screen does. Anything the new code imports is
installed into the draft first, so adding a dependency between runs works.
Media you uploaded yourself is kept. A push carries the whole set: repeat
`--demo` to add demos, drop one from the command to remove it, and edited
`--description`, `--name` or `--tags` travel with the code. The slug and the
registry are fixed when the draft is created, since they decide what it
publishes as.
The component slug and the set of demos are fixed when the draft is created, so
a push changes code only; add `--no-push` to resume a draft without touching
its source, for example to finish a publish that was interrupted.

With `--json`, stdout carries exactly one JSON document (`state`, and on
success `component_id`, `url`, `install_ref`); all progress moves to stderr.
Exit codes are stable for scripting: `0` published, `1` generic failure,
`2` draft handed off without publishing (CI), `3` auth, `4` rate limited,
`5` build failed, `6` cover/media not ready, `7` conflict, `130` interrupted.

To read a draft the same way without publishing, `21st draft <draft:uuid>`
prints its state, editor URL and per-demo media states; `--watch` streams
every transition until the draft publishes, fails or is deleted.

Common flags:

| Flag | Purpose |
| - | - |
| `--description` | Short description (recommended) |
| `--component component:<id>` | Revise this exact existing component |
| `--to <library-slug>` | Publish into a specific team library |
| `--name` / `--slug` | Override the auto-detected name/slug |
| `--tags a,b,c` | Set tags explicitly |
| `--demo <file>` | Use a specific demo file (repeat for more) |
| `--preview <img>` | Use this image as the demo's cover |
| `--no-open` | Print the draft URL without opening Studio |
| `--registry ui\|hooks\|blocks\|icons` | Registry kind |
| `--visibility published\|private` | Access (default `published`) |
| `--website <url>` | Link a live site |
| `--registry-dep <dep>` | Not supported by CLI Review yet |
| `--prepare` | Prepare media without publishing |
| `--auto` | Publish after required media is ready |
| `--wait-video` | Require successful generated video |
| `--media-dir <dir>` | Download generated media for inspection |
| `--draft draft:<uuid>` | Push this file into that draft and resume |
| `--no-push` | Resume without replacing the draft's source |

See [Publishing → Quick Start](https://help.21st.dev/publishing/quick-start.md) for the full flow and requirements.

### Controls come from the demo file

A demo that declares a module-level `const settings = { … }` and takes it as
props publishes with a live controls panel next to its preview, and visitors
copy code carrying the values they tuned. The CLI needs no flag for it: the
defaults are read from the source you publish. Labels and ranges are edited
afterwards from the component's **Edit** dialog without a re-publish, but which
knobs exist and what they start at change only by publishing again. See
[Demo Controls](https://help.21st.dev/publishing/demo-controls.md).

> [!NOTE]
>
> The current CLI Review command sends one self-contained component source file
> and one demo. Additional local files, `21st.json`, and registry dependencies
> are not supported for either a new component or an owned revision yet.

### Review the CLI draft before publishing

The build check cannot detect every runtime, interaction, or theme problem.
Before publishing, confirm that the build passed, every imported package is
declared in the nearest `package.json`, and every demo works in the right-side
live preview. Test meaningful states in both light and dark themes, including
that the primary color resolves correctly.

Use semantic Tailwind utilities such as `bg-primary` and
`text-primary-foreground`. For custom CSS, use Tailwind v4 variables such as
`var(--color-primary)`. Do not write `oklch(var(--primary))` or
`hsl(var(--primary))`: projects can represent raw tokens differently, making
otherwise valid CSS render the wrong color in Studio. Use an opacity utility
such as `bg-primary/20`, or `color-mix()` with `var(--color-primary)`.
The CLI rejects these known non-portable raw-token wrappers before it creates a
draft.

Studio starts media generation as soon as the draft is ready. It prioritizes the
required cover, which must be ready before publishing. The optional video is
best-effort in the background: publishing never waits for it and includes it
only if it is ready. An interaction video is accepted only when a click, press,
typing, keyboard, or scroll beat produces a visible result. Give interactive
controls stable semantic selectors such as an `id`, native role, or
`data-slot`; a missing selector or a visually unchanged interaction is retried
once and then fails closed instead of attaching a cursor-only clip. You can
replace either generated asset manually.

If the component is blank, throws, has unresolved dependencies, or renders the
wrong primary color, fix the source in CLI Review and save it. Studio signs the
new source revision, invalidates every cover and video from the old revision,
and queues fresh media with the required cover first. Publishing stays blocked
until that new cover is ready or you upload a replacement. An auto-generated
cover does not replace the visual and interaction review.

> [!NOTE]
>
> Private personal components are visible only to you. Publishing privately to a
> Team library requires an active Team plan and owner or admin access.

Publishing and catalog review are separate. A Published component is available
by link and on your profile. Submit it for featuring only when it is ready:

```bash theme={null}
21st submit <slug>
21st withdraw <slug>
21st resubmit <slug>
21st remove-from-catalog <slug>
```

## When a publish fails

A failed publish prints what went wrong, which step it happened in, and the
build output itself:

```text theme={null}
Publish failed (HTTP 422): The "default" demo contains a code or import error. Open the build details, fix the error, and publish again.
  Stage: component build (demo "default")
  ---
  src/demos/default.tsx:7:22 - error TS2304: Cannot find name 'Butonn'.
  ---
  Request ID: iad1::abcde-1745000000000-0123456789ab
```

Fix your source for a build error and publish again. For a temporary failure,
publish again as-is. Quote the request ID if you contact support: it identifies
the exact request on our side.

| Error | What it means | What to do |
| - | - | - |
| `dependency_install_failed` | A dependency could not be installed | Check the name and version, then republish |
| `draft_dependency_install_failed` | A new draft dependency could not be installed | Fix an invalid package/version, or retry a temporary network failure |
| `draft_build_failed` | The new draft component or demo does not build | Fix the reported source and publish again |
| `draft_readiness_unavailable` | Draft install/build/preview readiness timed out | Retry with the same source |
| `unsupported_draft_files` | A new draft includes extra local source files | Publish one self-contained component and demo |
| `unsupported_draft_registry_dependencies` | A new draft declares a registry dependency | Remove it or update an existing owned slug |
| `registry_generation_failed` | Your files could not be prepared for publishing | Read the output, fix, republish |
| `component_build_failed` | The component or its demo does not compile | Fix the reported file, republish |
| `publish_command_timed_out` | A build step ran past its limit | Retry; if it repeats, simplify the demo |
| `publish_runner_unavailable` | Our build service was briefly unreachable | Retry in a minute, your files are safe |
| `artifact_upload_failed` | It built, but the files could not be uploaded | Retry |
| `publish_persistence_unavailable` | It built and uploaded, but could not be saved | Retry |
| `publish_completion_uncertain` | It may have gone through, we could not confirm | Check your profile before republishing |
| `cli_draft_waking` | The draft's workspace was still waking up | Nothing: the CLI waits and sends the source again |
| `database_busy` | Our database was busy for a moment | Nothing: the CLI retries after `Retry-After` seconds |

The JSON body of a failed `POST /api/v1/components/publish` carries the same
information: `error` (the code above), `message`, `retryable`, `request_id`, and
`details` with `stage`, `demo_slug` or `dependency`, and `output`. Retry only
when `retryable` is `true`. The rest will fail the same way until the source
changes.

## Publish a theme

```bash theme={null}
21st publish-theme ./theme.css --name "Midnight" --tags dark,minimal
```

The CSS file must contain both `:root` and `.dark` blocks.

## Publish a template

```bash theme={null}
21st publish-template "My SaaS starter" \
  --site https://demo.example.com \
  --preview ./preview.png \
  --price 49 \
  --buy-url https://gumroad.com/l/my-starter \
  --description "A full Next.js SaaS starter" \
  --video https://youtu.be/xyz \
  --tags 12,45
```

Submits a template listing for moderation (it lands as a draft). For paid templates, set `--price` and a `--buy-url` checkout link. See [Selling & promotion](https://help.21st.dev/publishing/monetization.md).

## Edit your content

```bash theme={null}
21st edit component:<id> --type component --visibility published
21st edit <id|slug> --type theme --name "New name" --tags a,b
```

`--type` is `component`, `theme`, or `template`. Component metadata edit and
delete accept a saved `21st login` session or API key. A Team manager can manage
a teammate's component metadata, but only its original author can check out a
code revision. Theme/template management still requires an API key. Editable
fields differ per type (templates use numeric tag ids and have no visibility
field).

## Unpublish or delete

```bash theme={null}
21st delete component:<id> --type component --yes
21st delete draft:<uuid> --type draft --yes
```

`--yes` is required to confirm. For components and themes this **unpublishes** (sets visibility to private / clears the published date). For templates it is a **permanent delete**.
Deleting a draft permanently removes its unpublished sandbox and code.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.