Deploy
Deploy to any container host, Fly.io, Railway, Render, Vercel, or Netlify, with migrations before each release.
Choose the platform with --deploy when you create the project, or switch later with pnpm clubedge add deploy <option>. The default is docker, for any container host. Each other option adds the platform's configuration file and its job in the deploy workflow.
On Railway, Fly.io, Vercel, Netlify, and Render, one command does the first deploy and every release after it: pnpm clubedge deploy signs in, creates what the app runs on, sets the variables, and waits until the release is live. With docker, it sets up a server of your own: Docker Compose behind Caddy, with the images published on each release (CLI 0.42.0 or newer). For a frontend and its API, it sets up the pair with Docker Compose or on Railway, and for a project without a website, the API alone. The pages below cover the same setup by hand.
Platforms
| Platform | Option | Runs | Migrations | Configuration |
|---|---|---|---|---|
| Any container host | docker | The production image, or Docker Compose behind Caddy | The migrator, as a one-off task before each rollout | Dockerfile, and compose.yaml from deploy |
| Fly.io | fly | The production image | The release command | fly.toml |
| Railway | railway | The production image | The pre-deploy command | .railway/railway.ts |
| Render | render | The production image | The pre-deploy command (paid instance types) | render.yaml |
| Vercel | vercel | Serverless functions | The build command | apps/web/vercel.json |
| Netlify | netlify | Serverless functions | The build command | apps/web/netlify.toml |
Container platforms run the same image everywhere, with a worker for background jobs and a step before each release for the migrations. Vercel and Netlify only run the app: the database, Redis, storage, and email come from your providers, migrations run in the build, and a scheduler replaces the worker.
A frontend and its API
A project with a frontend and its API offers only docker and railway, and runs as two services from two images: the root Dockerfile, the frontend, whose Node server (node server.mjs) serves the build and forwards the API routes to API_URL; and apps/api/Dockerfile, the API, which contains the migrator. The frontend is public and the API can stay private.
docker: run both images on any container host, with the migrator from the API's image before each new version.pnpm clubedge deploywrites acompose.yamlthat runs both behind Caddy, the API on the Compose network behind the frontend.railway: a public frontend service and a private API service; see Railway.pnpm clubedge deploycreates both.
Fly.io, Render, Vercel, and Netlify aren't offered for the pair yet. A mobile app or a native app runs no server, so it isn't deployed: it calls the API through the deployed frontend.
Without a website
A project without a website (Starter v0.28.0 or newer) is its API, which clients reach directly. It offers only docker and railway, and runs as one public service from the API's image, apps/api/Dockerfile, which contains the migrator:
docker: run the image on any container host, with the migrator before each new version.pnpm clubedge deploywrites acompose.yamlthat runs it behind Caddy, at your domain.railway: one service,<package>-api, with the public*.up.railway.appdomain; see Railway.pnpm clubedge deploycreates it.
Its variables are those of apps/api/.env.example, with its host's client address setting, since clients reach it directly. With Better Auth, which runs in the API, they include BETTER_AUTH_SECRET and BETTER_AUTH_URL, the API's public URL. The native app isn't deployed: set its EXPO_PUBLIC_API_URL to the API's https:// address for its release builds.
Preview environments
With --infra neon, each pull request gets its own Neon branch with its migrations, a schema diff comment, and a preview on Vercel or Railway. See Preview environments.
The deploy workflow
.github/workflows/deploy.yml deploys on demand: in GitHub, open Actions, then Deploy, then Run workflow. Each platform's page lists the secrets it needs.
From Starter v0.27.0, a project that deploys with docker has no deploy workflow: pnpm clubedge deploy writes .github/workflows/release-images.yml, which publishes the images on each GitHub release. See Any container host.
Health and readiness
/api/health answers as long as the app runs, so platforms use it to decide whether to restart the app. /api/ready also checks that the database answers, returning 200 or 503 without details: point load balancers and readiness probes at it, so traffic waits while the database is unreachable instead of the app restarting.
With a separate API, both are the API's, and the frontend forwards them. Check the API service at its own /api/health, and the frontend service at /, as pnpm clubedge deploy does. Without a website, the API answers them itself.
Production variables
A project only needs the variables of its modules:
DATABASE_URL, pointing at a managed PostgreSQL database.- The deployed origin:
NEXT_PUBLIC_APP_URLwith Next.js, orAPP_URLwith TanStack Start. Next.js compilesNEXT_PUBLIC_APP_URLinto the build, so it must be set when the app or image is built. - Supabase Auth: the Supabase URL and publishable key from the project, and
SUPABASE_SECRET_KEYif users should be able to delete their account. - Better Auth:
BETTER_AUTH_SECRET, at least 32 random characters, different from development. Without a website, alsoBETTER_AUTH_URL, the API's publichttps://URL, whichpnpm clubedge deploysets. - Firebase:
FIREBASE_PROJECT_ID,FIREBASE_API_KEY, and the service account'sFIREBASE_CLIENT_EMAILandFIREBASE_PRIVATE_KEY;FIREBASE_AUTH_EMULATOR_HOSTunset. - Appwrite:
APPWRITE_ENDPOINT,APPWRITE_PROJECT_ID, andAPPWRITE_API_KEY. - Email:
SMTP_URLorRESEND_API_KEY, andEMAIL_FROM. Without them, production refuses to send email. - Payments:
STRIPE_SECRET_KEY(live mode),STRIPE_WEBHOOK_SECRETfrom the production webhook endpoint, andSTRIPE_PRICE_<PLAN>for each plan. - Redis:
REDIS_URL, when you run more than one instance. - Jobs: with pg-boss or BullMQ,
CRON_SECRET, where no worker runs and a scheduler calls/api/jobs/run. With Inngest,INNGEST_EVENT_KEYandINNGEST_SIGNING_KEYfrom your Inngest app, andINNGEST_DEVunset. - OpenTelemetry:
OTEL_EXPORTER_OTLP_ENDPOINT, andOTEL_EXPORTER_OTLP_HEADERSif your collector needs a key. - Sentry:
SENTRY_DSN, andSENTRY_ENVIRONMENTto tell environments apart. - Storage: the
STORAGE_*variables for your S3-compatible bucket, orSUPABASE_STORAGE_BUCKET. - Client addresses:
CLIENT_IP_HEADERorTRUSTED_PROXY_HOPS, for where the app runs (Starter v0.27.0 or newer). See Client addresses.
pnpm check:env checks them against the project's modules (Starter v0.18.0 or newer): it lists each one that is unset, points at localhost, or isn't an absolute URL. Vercel and Netlify builds run it first.
With a separate API
The two services need different variables:
- The frontend:
API_URL, the API's address, read when the server starts. TheVITE_*values of your auth provider, which Vite compiles into the build, so they must be set where the frontend is built (Docker build arguments, or the Railway service's variables). With Better Auth, alsoDATABASE_URL,BETTER_AUTH_SECRET, andBETTER_AUTH_URL(the frontend's public origin), since Better Auth runs in the frontend's server. Your host's client address setting goes here too. - The API:
DATABASE_URL,FRONTEND_URL(the frontend's public origin), and your auth provider's server variables. See Authentication. Every other module's variables from the list above go here too. Reached only through the frontend, it takesTRUSTED_PROXY_HOPS=1. With a mobile app or a native app, alsoAPP_MINIMUM_VERSION,APP_LATEST_VERSION, andAPP_UPDATE_URL, and from Starter v0.29.0 an announced minimum and values for each platform: see Apps installed on phones.
Stripe's webhook endpoint (https://<your-frontend>/api/webhooks/payments), Inngest's app URL (https://<your-frontend>/api/inngest), and a scheduler calling /api/jobs/run use the frontend's public URL, which forwards them to the API, so the API stays private.
There, pnpm check:env runs the API's own check of its modules' variables, as above: with Hono from Starter v0.25.0, and with FastAPI from Starter v0.26.0. Before, it only required DATABASE_URL.
Before going live, work through Before deploying.
How is this guide?