Requirements
- Node.js 22 or newer and pnpm 10 or newer.
- A Postgres 18 database. See Database.
- Two secrets: a long random string for
BETTER_AUTH_SECRET, and another of at least 16 characters forENCRYPTION_KEY.
Deployment steps
-
Get the code and install.
-
Set the environment.
Create a
.envfile in the project root with the database and secrets. The minimum is: -
Start the server.
It listens on port 3000 (
PORTchanges it) and runs pending migrations first. -
Build the studio.
Serve the
apps/studio/distfolder from any static host, at the address given asSTUDIO_ORIGIN.
Requirements and pitfalls
- Secrets: without
BETTER_AUTH_SECRETthe server falls back to a development secret and warns. Never run that way in production.ENCRYPTION_KEYprotects the credentials people give to modules. It must be kept safe and must not change, or stored connections become unreadable. - Addresses:
BETTER_AUTH_URLis the server’s public address.STUDIO_ORIGINis the studio’s. The server only accepts requests from that origin. - One domain: if the studio is served and
/apiis routed to the server on the same address, leaveVITE_API_URLunset when building, and the studio uses the same origin. - Live updates: the studio listens to a long-lived event stream. A proxy in front must have response buffering turned off for it.
- Sign in with Google: set
GOOGLE_CLIENT_IDandGOOGLE_CLIENT_SECRET, and register<BETTER_AUTH_URL>/api/auth/callback/googleas the redirect address.
Related
- Environment variables: every setting.
- Database: embedded or Postgres, and migrations.
- Turn on agents: add an AI provider key.