Skip to content

Set Up and Deploy

Terminal window
pnpm run setup

Setup is the guided installer. On a fresh install it:

  1. Checks that Wrangler is authenticated.
  2. Creates the D1 database and R2 bucket, or reuses ones already configured.
  3. Applies database migrations.
  4. Generates and stores BETTER_AUTH_SECRET.
  5. Offers to configure email (optional; see Email).
  6. Deploys the API Worker.
  7. Sets BETTER_AUTH_URL to the API’s real URL, only while it is still the pre-deploy placeholder.
  8. Builds and deploys the Admin Worker against that API URL.
  9. Stores the Admin Worker’s URL as the ADMIN_URL secret and adds its origin to CORS_ORIGINS, then redeploys the API.

It ends by printing both Worker URLs and the commands for the next step, creating the Owner.

The deployment runs the release npm create checked out, which is always the latest one. Settings → Updates in the admin shows its version.

Command When What it does
pnpm run setup Once, for the first deployment Creates Cloudflare resources, secrets and configuration, then deploys
pnpm run update For every new release after that Moves the code to the latest release, applies migrations and redeploys. Never touches secrets, resources or configuration

See Update the CMS for the full update flow.

On an existing install, setup shows a status summary and a menu: continue without changes, update configuration, reconfigure everything, or cancel. It never overwrites a real BETTER_AUTH_URL, never rotates BETTER_AUTH_SECRET without an explicit confirmation (rotating it signs everyone out), and does not append a duplicate CORS origin.

Running setup again does not update the CMS to a newer release; use pnpm run update for that. To change one setting, use the pnpm run update -- --auth, --email, --domain family described there.

D1, R2 and Worker names only need to be unique within your Cloudflare account. If a default name is already used there (for example by another deployment of the CMS in the same account), setup asks for a different name instead of failing or overwriting. It also refuses to deploy over a Worker that belongs to a different deployment. See Setup troubleshooting.