create-headroom-site
v0.3.1
Published
Scaffold a new Headroom CMS frontend site (Astro or Next.js)
Readme
create-headroom-site
Scaffold a new Headroom CMS frontend site (Astro or Next.js), pre-wired to an existing Headroom install.
Usage
Interactive (prompts for framework, admin URL, login, and site):
pnpm create headroom-sitePass the project directory as a positional argument to skip the first prompt:
pnpm create headroom-site my-appNon-interactive / CI
With --admin-url, --email, and either --password or --password-stdin,
the scaffolder runs without prompts. Alternatively, pass a pre-provisioned
--api-key to skip admin login and key creation entirely.
| Flag | Description |
|------|-------------|
| --directory <path> | Project directory (positional also accepted) |
| --framework <name> | astro or nextjs |
| --admin-url <url> | Headroom admin URL or API URL |
| --media-url <url> | Headroom media CDN URL (skips discovery fallback prompt) |
| --email <email> | Admin email |
| --password <password> | Admin password (visible in shell history) |
| --password-stdin | Read admin password from stdin |
| --site <host> | Site host to use (skips selection prompt) |
| --api-key <key> | Pre-provisioned API key (skips login / key creation) |
| -h, --help | Show this help |
Fully non-interactive, piping the password from stdin (keeps it out of shell history):
echo "$PASSWORD" | pnpm create headroom-site my-app \
--framework astro \
--admin-url https://headroom-admin.example.com \
--email [email protected] --password-stdin \
--site mysite.comBring your own API key (skips admin login and key creation):
pnpm create headroom-site my-app \
--framework astro \
--admin-url https://api.example.com \
--site mysite.com \
--api-key headroom_xxxxxWhat It Does
- Resolves the admin / API URL from
--admin-urlvia a discovery document (also picks up the media CDN URL; falls back to a prompt or--media-urlon older deploys). - Logs in as an admin with your email + password — or, with
--api-key, takes the pre-provisioned key and skips login entirely. - Picks or creates the target site (from
--siteor an interactive selection). - Issues a
bootstrap-<framework>-…API key on that site (login path only). - Copies the framework template into the project directory.
- Writes
.envwithHEADROOM_API_URL,HEADROOM_MEDIA_URL,HEADROOM_SITE, andHEADROOM_API_KEY. - Runs
git initin the new project (best-effort — a missinggitbinary logs a warning and never aborts the scaffold). - Writes
.headroom/credentials so theheadroomCLI works from inside the project: aconfig.jsonpinning the URLs, active site, and CDN key, plus (in the login path) a0600token file holding the refresh token.
Generated Project Structure
my-app/
├── .devcontainer/
│ └── devcontainer.json # Ready-to-test container with pnpm + Playwright CLI
├── .headroom/ # CLI credentials (gitignored) — config + refresh token
├── .env # HEADROOM_* connection vars (written at scaffold time)
├── .env.example # Committed template of the connection vars
├── .gitignore
├── CLAUDE.md # Full project guide (framework specifics, workflows)
├── package.json
├── src/ # Pages, components, layouts, SDK client
└── scripts/
└── generate-schemas.* # Generate typed content schemas from the CMSSee the generated CLAUDE.md for the full guide to the project — its layout,
data flow, and framework-specific workflows.
Next Steps
cd my-app
pnpm install
pnpm devOr open the project in the included devcontainer — it provisions Node, pnpm, and the Playwright CLI + browsers on create, so the dev server and browser tests run out of the box.
pnpm exec headroom whoami works immediately because the scaffolder saved your
connection settings to .headroom/ — and, if you logged in as an admin, your
refresh token too. (In the --api-key path no admin token is written; whoami
still runs and reports the saved connection, just without an authenticated
admin session.)
Prerequisite:
git. The scaffolder runsgit init, and theheadroomCLI resolves its.headroom/config from the git root. Ifgitwas not installed when you scaffolded (thegit initstep was skipped with a warning), rungit initin the project before using the CLI so it finds the credentials.
Security:
.headroom/holds a refresh token. It is gitignored (both by the project.gitignoreand by.headroom/.gitignore), so it stays out of commits. If you force-add it, you are committing a credential that grants admin access — don't.
Frameworks
- Astro — content-focused static/SSR site; dev server on port 4321.
- Next.js — React App Router site; dev server on port 3000.
Choose interactively or with --framework astro / --framework nextjs.
License
PolyForm Noncommercial 1.0.0
