Skip to content

Set Up and Deploy

Terminal window
pnpm run setup

Setup is the installer for a first deployment. It:

  1. Checks that Wrangler is authenticated.
  2. Creates or configures the D1 database and the R2 bucket.
  3. Applies database migrations.
  4. Generates and stores the Better Auth secret.
  5. Deploys the API Worker and determines its real URL.
  6. Sets BETTER_AUTH_URL to that URL.
  7. Builds and deploys the Admin Worker.
  8. Adds the Admin Worker origin to the API’s CORS allow-list.

When it finishes it prints the deployed Worker URLs.

Setup detects an existing installation and offers: continue without changes, update a configuration area, reconfigure everything, or cancel. It does not re-create resources that exist, and it does not overwrite a BETTER_AUTH_URL that is already set to a real value.

For routine code updates use pnpm run update instead.

If a D1 database, R2 bucket or Worker name is already used in your Cloudflare account, setup asks for a different name rather than overwriting it. See Setup troubleshooting.