New:New releases:CLIcreate-clubedge-app v0.49.1·Clubedge Starter v0.32.0

Clubedge Starter Docs

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

PlatformOptionRunsMigrationsConfiguration
Any container hostdockerThe production image, or Docker Compose behind CaddyThe migrator, as a one-off task before each rolloutDockerfile, and compose.yaml from deploy
Fly.ioflyThe production imageThe release commandfly.toml
RailwayrailwayThe production imageThe pre-deploy command.railway/railway.ts
RenderrenderThe production imageThe pre-deploy command (paid instance types)render.yaml
VercelvercelServerless functionsThe build commandapps/web/vercel.json
NetlifynetlifyServerless functionsThe build commandapps/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 deploy writes a compose.yaml that 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 deploy creates 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 deploy writes a compose.yaml that runs it behind Caddy, at your domain.
  • railway: one service, <package>-api, with the public *.up.railway.app domain; see Railway. pnpm clubedge deploy creates 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_URL with Next.js, or APP_URL with TanStack Start. Next.js compiles NEXT_PUBLIC_APP_URL into 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_KEY if users should be able to delete their account.
  • Better Auth: BETTER_AUTH_SECRET, at least 32 random characters, different from development. Without a website, also BETTER_AUTH_URL, the API's public https:// URL, which pnpm clubedge deploy sets.
  • Firebase: FIREBASE_PROJECT_ID, FIREBASE_API_KEY, and the service account's FIREBASE_CLIENT_EMAIL and FIREBASE_PRIVATE_KEY; FIREBASE_AUTH_EMULATOR_HOST unset.
  • Appwrite: APPWRITE_ENDPOINT, APPWRITE_PROJECT_ID, and APPWRITE_API_KEY.
  • Email: SMTP_URL or RESEND_API_KEY, and EMAIL_FROM. Without them, production refuses to send email.
  • Payments: STRIPE_SECRET_KEY (live mode), STRIPE_WEBHOOK_SECRET from the production webhook endpoint, and STRIPE_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_KEY and INNGEST_SIGNING_KEY from your Inngest app, and INNGEST_DEV unset.
  • OpenTelemetry: OTEL_EXPORTER_OTLP_ENDPOINT, and OTEL_EXPORTER_OTLP_HEADERS if your collector needs a key.
  • Sentry: SENTRY_DSN, and SENTRY_ENVIRONMENT to tell environments apart.
  • Storage: the STORAGE_* variables for your S3-compatible bucket, or SUPABASE_STORAGE_BUCKET.
  • Client addresses: CLIENT_IP_HEADER or TRUSTED_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. The VITE_* 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, also DATABASE_URL, BETTER_AUTH_SECRET, and BETTER_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 takes TRUSTED_PROXY_HOPS=1. With a mobile app or a native app, also APP_MINIMUM_VERSION, APP_LATEST_VERSION, and APP_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?