Skip to content

CLI quickstart

This takes about ten minutes. You end with a component published to Staging and showing on a page of your own.

Prefer an MCP client to the CLI? Connect an MCP client to Taggor: add the server, sign in and approve access.

  • Node 20 or newer.
  • A Taggor account on the portal, https://app.taggor.dev/. Creating the account and approving the CLI's sign-in are done by a person in the browser; the CLI never asks for a password.
  • A page where you can add a script tag. A test page served from your own computer is enough.

Run it from any folder. The first npx taggor downloads the package from the npm registry:

Terminal window
npx taggor --version
Terminal window
npx taggor login
npx taggor whoami

login prints a code and a URL, then waits. Open the URL, check that the code matches and approve the sign-in. whoami shows your user, workspace and role. If it shows no workspace, pick one with npx taggor workspaces use <workspace-slug>.

Without a browser (a server or a CI job), skip login: set TAGGOR_API_KEY to an API key from the portal (Settings, then API keys). The key wins over any login, and whoami shows Signed in with: TAGGOR_API_KEY. TAGGOR_API_URL sets the API origin the CLI talks to.

Terminal window
npx taggor init

init creates a small project for your workspace in a folder Taggor keeps, ~/.taggor/projects/<workspace>/, and prints its path with the cd line that goes into it. It needs the sign-in of step 2, so it knows which workspace the project is for. Copy the cd line init printed and run it, then install in that folder:

Terminal window
npm install

You do not need GitHub or a repository. Every publish stores the component's source in Taggor, and npx taggor pull brings it back (see the end of this step). If you want the project in a folder or a repository of your own anyway, run npx taggor init . (or npx taggor init <folder>) there instead; that works without signing in.

The project has taggor.json (your workspace and the list of your components), package.json, tsconfig.json, and a first component in components/hello-component/src/index.tsx with its styles. Pass --component <tag> to name it; a tag needs a hyphen, for example price-table. Run init --component <tag> again in the same project to add another component. npx taggor projects list shows the folders Taggor keeps and which components were never published.

npm install adds the SDK, @taggor/component, Preact and the taggor CLI itself.

Open components/hello-component/src/index.tsx: it is one defineTaggorComponent call. What it can declare is in the component contract.

Once you have published, the source is in Taggor. npx taggor pull brings back every component of your workspace, with the project around them, on this computer or another one; --dir <folder> picks the folder. A component you changed and never published is not overwritten unless you pass --force. npx taggor pull <component> brings one component, and takes --version or --channel.

Terminal window
npx taggor dev

This serves your components on http://127.0.0.1:4321 (change it with --port <n>) with hot reload. The test page imitates what a real site can do to a component: it applies aggressive CSS and scripts, as a site's own might, so a problem shows before a visitor sees it. Each component has a card with:

  • Two backgrounds, light and dark, side by side. The eye icon on a background hides it, for every component on the page.
  • Props, with a control for each declared type. A value the contract refuses is not applied, and the line names the field and the limit, for example tiers[0].features: needs at least 2 items, has 1.
  • CSS variables, one free-text field for each variable the component declares. Clear the field and the component's own default returns.
  • Live events: what the component emits, the clicks and inputs inside it, the metrics it tracks and the submissions it sends (the submissions stay on your machine), with the warnings and errors of the runtime.

--host-html <file> previews on a page of your own; the same panels then float over it. The private preview link of a published version shows the same page.

Terminal window
npx taggor check

Runs the publication gates (types, size, security) on your machine, with no sign-in. It exits with code 6 when a gate fails; each failure prints a code that has a page under build diagnostics.

The first check or dev downloads the local engine from the portal once (about 1 MB) and keeps it in ~/.taggor/engine/, so later runs work offline. With no network and no kept copy they stop and say so; publish still works, because it builds and checks on Taggor.

Terminal window
npx taggor sites create --name "My site"

One site has two environments, and the command prints a snippet for each:

  • The staging snippet goes on the test copy of your website and on pages on your own computer. It shows the version on the component's Staging channel.
  • The production snippet goes on your live website. It shows the version on the component's Production channel.

Each snippet has its own site key (st_ and 10 characters), and the output names the environment of each one, so you never have to guess which is which. The command also prints the site's id (st_ and 26 characters): write it down. The project keeps no default site, so the commands that act on a site take it with --site, and npx taggor sites list shows your sites again. The next steps write the id as SITE_ID: put your own there.

The staging snippet always works on localhost and 127.0.0.1, so a test page on your computer needs nothing else. Sites and environments has the rest: the domains of each environment, what each one shows and how to hold one on a version.

Terminal window
npx taggor publish --site SITE_ID

publish packs the source of each component in taggor.json, builds it remotely, creates a version, moves the Staging channel to it and attaches the component to the site you named with --site. The output ends by saying what each environment of the site shows now, and prints the staging snippet again:

Sites that have hello-component attached, and what each environment serves now:
My site (st_…)
production serves nothing: hello-component has no version on the production channel. To put one there: taggor promote hello-component --channel production
staging serves 1.0.0 (ver_…): it follows the staging channel

That is the expected result: publish only moves Staging, so the staging snippet shows the new version and the production snippet shows nothing until you promote (step 9).

  • Without --site: the component is published and you get a preview link, but it is attached to no site, so no page shows it yet. Attach it later with npx taggor attach COMPONENT --site SITE_ID.

To see a version again later, run npx taggor preview <component> (add --version or --channel to pick one): it prints a new private link every time, builds nothing and spends no build. Anyone who has the link can open it, so share it on purpose; a link works for 7 days.

Nothing is sent before the local checks pass, and a file that looks like a secret stops the upload. Add --dry-run to see what would be sent. Add --json to any command for machine-readable output.

Terminal window
npx taggor sites snippet SITE_ID --environment staging

Prints the staging snippet under a comment that names it. Paste it into a test page, and write the component's tag where it should appear:

<!doctype html>
<html>
<body>
<hello-component></hello-component>
<!-- Taggor staging snippet, site key st_… -->
<script async src="https://cdn.taggorcdn.com/s/st_….js"></script>
</body>
</html>

Serve the page from your computer, then open localhost:8000 in your browser (plain http, no https):

Terminal window
python3 -m http.server 8000 --bind 127.0.0.1 --directory FOLDER_WITH_ONLY_THE_TEST_PAGE

The component appears. From now on every npx taggor publish reaches this page within about two minutes, with no change to the page. Install the snippet explains where the snippet goes and what the visitor sees before the component loads, or if it never does. Props explains how the page, the site and the component each give a prop its value.

When the version on staging is the one you want visitors to see:

Terminal window
npx taggor sites domains set --site SITE_ID --environment production --domain example.com
npx taggor promote COMPONENT --channel production
npx taggor sites snippet SITE_ID --environment production

The first command says where the production snippet may run (replace example.com with the hostname of your live website), the second moves the Production channel to the version Staging has (replace COMPONENT with the component's tag), and the third prints the production snippet for the live website. npx taggor sites show SITE_ID shows, at any time, both snippets and what each environment serves and why.

To do this Run
See what each environment of a site shows, and why npx taggor sites show SITE_ID
See the versions and channels of a component npx taggor versions <component>
Move Production to a version npx taggor promote <component> --channel production
Go back to the previous version npx taggor rollback <component> --channel production
Hold one environment of a site on a version npx taggor pin <component> --site SITE_ID --environment staging --version <version>
Let it follow its channel again npx taggor unpin <component> --site SITE_ID --environment staging
Change the domains of one environment npx taggor sites domains set --site SITE_ID --environment staging --domain <hostname>
Save a site's value for a component's prop npx taggor sites props set <component> <prop> <value> --site SITE_ID
List the components, or the archived ones npx taggor components list, npx taggor components list --archived
Archive a component, and bring it back npx taggor components archive <component>, npx taggor components restore <component>
Take a site off the air, and bring it back npx taggor sites disable SITE_ID, npx taggor sites enable SITE_ID
Rename a site npx taggor sites update SITE_ID --name <name>
Delete a site for good (it asks for a clear yes) npx taggor sites delete SITE_ID
Bring your components back, on any computer npx taggor pull
Follow a build npx taggor logs <component> --follow
List every command, or one command's options npx taggor --help, npx taggor pin --help

When a command fails, the message says what to run next, and ends with the code of the error and a link to its page in API and CLI errors.