A frontend and its API
A React + Vite frontend with a separate API in TypeScript or Python, joined by one HTTP contract.
pnpm dlx @clubedge/create-clubedge-app my-app --framework vite --api honoInstead of a full-stack framework, a project can be two apps: a React + Vite frontend in apps/web and a separate API in apps/api. They meet at one HTTP contract, so the API can be written in another language, or replaced later, without touching the frontend. It needs CLI 0.33.0 or newer (Starter v0.22.0); the FastAPI API needs CLI 0.34.0 (Starter v0.23.0).
When to choose it
| Choose | When |
|---|---|
A full-stack framework (next, tanstack-start) | One app renders the pages and runs the server code. Every module and deploy target is available. |
A frontend and its API (vite with --api) | You want the API as its own service, in TypeScript or Python, with a contract between them. Both APIs have every module option, except pg-boss on FastAPI. |
No website (none with --api) | You want the API alone, for the native app or clients of your own. See Without a website. |
With either API, every option of auth, storage, cache, email, payments, jobs, and observability works: the API runs them, and the frontend has the billing and jobs cards and browser error reporting. Hono has them from CLI 0.39.0 (Starter v0.25.0), and FastAPI from CLI 0.40.0 (Starter v0.26.0), except pg-boss, which has no Python version. Both deploy with Docker Compose or on Railway. See Modules on these stacks.
The flags
| Flag | App | Where |
|---|---|---|
--framework vite | React + Vite single-page app (TanStack Router, client-only) | apps/web |
--api hono | Hono API on Node, reusing the Starter's packages | apps/api |
--api fastapi | FastAPI API in Python 3.12, managed with uv | apps/api |
--mobile expo | Optional: a native Android and iOS app with Expo, which calls the API through the website (CLI 0.44.0 or newer) | apps/mobile |
--shell capacitor | Optional: the frontend, packaged as an Android and iOS app with Capacitor (CLI 0.42.0 or newer) | apps/shell |
A frontend calls an API, so --framework vite needs --api. A full-stack framework has its own server, so it takes none: --api none is the default. An API can also stand alone, with --framework none (CLI 0.44.0 or newer): see Without a website.
React + Vite is a frontend and calls an API: choose one with --api (fastapi, hono).
Next.js has its own server, so it does not call Hono (TypeScript): choose a frontend, or --api none.Interactive runs offer Next.js, TanStack Start, React + Vite, and None. After React + Vite, they ask Which API should the apps call?, with Hono (TypeScript) and FastAPI (Python), then Add a native mobile app?, with Expo and None, and Package the web app as a mobile app?, with Capacitor and None. See The native app and The mobile app.
The project's package.json records the choice, as "framework": "vite" and "apps": { "api": "fastapi" }, for later add, remove, and upgrade runs.
What you get
apps/web: the frontend. It serves pages only and calls the API for everything else. With auth, it has the account settings page. The dashboard has the billing card with--payments stripeand the jobs card with--jobs, and the browser reports its errors with--observability.apps/web/.env.localholdsAPI_URL(the API's address) andVITE_API_URL, plus the provider's publicVITE_*settings with auth, such asVITE_SUPABASE_URLandVITE_SUPABASE_PUBLISHABLE_KEY. With Better Auth, the frontend serves/api/authitself, so it also hasDATABASE_URL,BETTER_AUTH_*, and the email variables.apps/api: the API, package@clubedge/api. It owns the database and the modules, and readsapps/api/.env.local(fromapps/api/.env.example):HOST,PORT=3001,FRONTEND_URL,DATABASE_URL,DATABASE_URL_DIRECT, the provider's server settings with auth, such asSUPABASE_URLorFIREBASE_PROJECT_ID, and every other module's variables, such asREDIS_URL,SMTP_URL, orSTRIPE_SECRET_KEY. The database commands read it too. With Hono, the module routes are insrc/routes, the composition root insrc/server, and the background jobs insrc/jobs. With FastAPI, everything is in the packagesrc/clubedge_api: the composition root inserver.py, a few files per module, such asstorage.pyorjobs.py, and the module routes inroutes/. See Project structure.packages/contract:openapi.yaml(the contract), the TypeScript client generated from it, and the conformance suite. Only projects with a separate API have it.
Run it
pnpm devpnpm dev starts both: the frontend on http://localhost:3000, and the API on port 3001. The frontend forwards /api to the API (its API_URL), so the browser sees one origin and cookies stay first-party.
pnpm start runs both from their builds: the API, and the frontend's Node server (server.mjs), which serves the build and forwards the API routes. docker compose up --build runs both images.
The frontend forwards only the contract's endpoints, and only those of the modules you chose: the billing routes and the Stripe webhook with --payments stripe, /api/jobs with --jobs, /api/inngest with Inngest, and /api/client-errors with --observability. Stripe, Inngest, and a scheduler calling /api/jobs/run reach the API through the frontend, so the API stays private.
The contract
packages/contract/openapi.yaml describes every endpoint. The frontend calls the API only through the client generated from it.
| Endpoint | Returns |
|---|---|
GET /api/health | Liveness: the status, the service id, and a timestamp. |
GET /api/ready | 200 when the database answers, 503 when it doesn't. Never cached. |
GET /api/session | The signed-in user, or null. |
GET /api/app-version | The app versions the API serves to apps installed on phones, for the platform they name, each null until set. Never cached. Starter v0.27.0 or newer. |
Each module adds its own endpoints, such as /api/account with auth, /api/billing with payments, and /api/jobs with jobs. An API without the module answers them with 404. The account settings' display name and deletion are an optional part of the auth module, the account capability: both APIs implement it, FastAPI from Starter v0.26.0.
Errors are JSON, such as { "error": { "code": "not_found", "message": "..." } }.
To change the API, edit the contract first, regenerate the client, then implement the change in the API:
pnpm --filter @clubedge/contract generateApps installed on phones
A mobile app or a native app calls the API, through the frontend's domain or, without a website, at the API's own, and keeps the version it shipped with, often for months. It asks GET /api/app-version which versions the API serves (the mobile app from Starter v0.27.0, the native app from v0.28.0), and both APIs answer with what you set in apps/api/.env.local, or in the API's environment in production. The answer is never cached, so a change applies on each app's next check, with no new release of the app. Each is null while unset:
APP_MINIMUM_VERSION, the oldest app version the API still serves: below it, the app shows a blocking update screen.APP_LATEST_VERSION, the newest released version: below it, the app may show an optional update notice.APP_UPDATE_URL, where to get the update: anhttps://link to the store listing or a download page.APP_NEXT_MINIMUM_VERSIONandAPP_NEXT_MINIMUM_VERSION_FROM(Starter v0.29.0 or newer), a minimum announced for a date and time with its time zone, such as2026-11-01T00:00:00Z. Until then, apps below it keep working and tell their users to update by that date; from then, the API requires it, with no redeploy.
From Starter v0.29.0, each can be set for one platform by adding _IOS or _ANDROID to its name: APP_UPDATE_URL_IOS for the App Store listing and APP_UPDATE_URL_ANDROID for Google Play, say, or APP_LATEST_VERSION_IOS while App Store review holds a release Google Play already has. The apps say which platform they run on, and the platform's own value wins over the shared one.
Versions are MAJOR.MINOR.PATCH, such as 1.4.0. The latest may not be older than the minimum, nor than the announced minimum, which must be newer than the current one. Other values fail the request rather than reach the apps, and pnpm check:env lists them before a deploy. The conformance suite checks the endpoint too.
Apps the API refuses
From Starter v0.29.0, the apps send their version (X-App-Version) and platform (X-App-Platform) with every request. To a request whose version is below the minimum, the API answers 426 update_required, on every route but /api/health, /api/ready, and /api/app-version, so an app left open for days shows its update screen at its next request, not only when it starts again. Apps built from an earlier Starter send no version: the API serves them, and they find a new minimum at their next start. Both APIs do it, and the conformance suite checks it.
The version is what the app says it is, so this keeps old apps from calling an API they no longer match: it isn't a security control. For an urgent fix, raise APP_MINIMUM_VERSION itself, and apps below it stop at their next request (earlier builds, at their next start). Once a security fix is out, don't lower the minimum again, even to roll back a broken release: ship a fixed version instead.
Keep the contract compatible
Installed apps keep calling the contract they shipped with, so change openapi.yaml only in ways they survive: add fields and operations, but never remove or rename them, and never make an optional request field required.
From Starter v0.27.0, the CI workflow's contract job compares each pull request's contract with its base branch's using oasdiff, and fails on a change that breaks existing clients. It compares them in CI only: the contract isn't uploaded anywhere. For a deliberate break before any app has shipped, label the pull request breaking-contract and run the job again. Once apps have shipped, a break also needs APP_MINIMUM_VERSION raised to the first version that handles it, so older apps ask for an update instead of failing.
Prove an API
@clubedge/contract/conformance is the test suite every API passes. The Hono API runs it in process, in its own tests. Any API, in any language, runs it over HTTP:
# In an API's package.json scripts (it depends on @clubedge/contract): start the API on a
# spare port, run the suite against it, and stop it. The FastAPI API's `test` script does this.
clubedge-contract-check -- uv run python -m clubedge_api
# Or against an API that is already running, from the project root
API_URL=http://127.0.0.1:3001 pnpm exec vitest run packages/contract/src/remote.test.tsThe APIs
Hono on Node, in TypeScript. It reuses @clubedge/core and @clubedge/db and is bundled with esbuild. Its image includes the migrator: run node migrate.mjs before a new version starts.
Production
Each app has its own image:
| Image | Runs |
|---|---|
Dockerfile | The frontend: a Node server (node server.mjs) that serves the build and forwards the API routes to API_URL, the API's address. |
apps/api/Dockerfile | The API: Node for Hono, python:3.12-slim with uv for FastAPI, with only your modules' dependency groups. Both include the migrator, node migrate.mjs. |
Run the two images on any container host, with the migrations before each new version, or let pnpm clubedge deploy set them up (CLI 0.35.0 or newer). In both cases the frontend is public and the API stays private, reached through the frontend's /api proxy. The modules' variables, such as REDIS_URL, SMTP_URL, or STRIPE_SECRET_KEY, go to the API. Stripe's webhook endpoint and Inngest's app URL are on the frontend's public URL, which forwards them to the API.
deploy reads the two services from clubedge.services in package.json, which the CLI records from CLI 0.35.0 on. For a pair created with an older CLI, deploy refuses until you run pnpm clubedge upgrade. deploy --preview deploys one app only, so it refuses on a frontend and its API.
With --deploy docker, deploy writes a compose.yaml that runs the frontend and the API as separate services behind Caddy, which serves the frontend over HTTPS for your DOMAIN, while the API stays on the Compose network (CLI 0.42.0 or newer). It also writes the Caddyfile and a workflow that publishes both images with each release. Copy the variables of .env.example and apps/api/.env.example to .env.production, fill in their values, migrate with the API's image, and start:
docker compose --env-file .env.production run --rm api node /app/migrate.mjs
docker compose --env-file .env.production up -d # --build builds the images on the serverThe frontend's VITE_* values are build arguments, compiled into its bundle. See Docker Compose. With CLI 0.35.0 to 0.41.1, the compose.yaml published the frontend's port, without Caddy.
Modules on these stacks
| Module | Hono | FastAPI |
|---|---|---|
auth | supabase, better-auth, firebase, appwrite, or none | supabase, better-auth, firebase, appwrite, or none |
storage | s3 (default), supabase, or none | s3 (default), supabase, or none |
cache | redis (default) or memory | redis (default) or memory |
email | smtp (default), resend, or none | smtp (default), resend, or none |
payments | stripe or none | stripe or none |
jobs | pg-boss, bullmq, inngest, or none | bullmq, inngest, or none |
observability | otel, sentry, or none | otel, sentry, or none |
deploy | docker or railway | docker or railway |
Auth on both APIs needs CLI 0.35.0 (Starter v0.24.0). The other modules need CLI 0.39.0 (Starter v0.25.0) on Hono and CLI 0.40.0 (Starter v0.26.0) on FastAPI, and a new project gets the same defaults as the full-stack apps: S3 storage, Redis, and SMTP email. pg-boss is the one exception: it has no Python version, so FastAPI runs jobs on BullMQ or Inngest. FastAPI projects from Starter v0.26.0 on need CLI 0.40.0 or newer: older CLIs leave Python files that fail ruff format.
Each module runs in the API, which holds its code, variables, and routes, and the frontend has its UI: the billing card, the jobs card, and browser error reporting. FastAPI implements each module in Python, with the same tables and migrations as Hono. With Better Auth, the frontend's auth server sends its emails with the same email provider. Each module's page has a section on these stacks, such as Background jobs.
With auth, the frontend has the sign-up, sign-in, and reset flows, and the account settings page, and the API verifies the provider's token or session on each request. With either API, the settings page has the display name, password change, and account deletion, which is refused while a subscription is active. CI runs the auth flows for every provider with both APIs. Local infrastructure (--infra) works as usual, and with --infra local, S3 storage uses a local folder. With --infra neon, the CLI writes the database URLs to apps/api/.env.local, since the API owns the database.
The CLI only offers the options the selected apps implement, in prompts, the builder, and add. When you don't choose, it falls back to a supported default; when you ask for one the apps don't implement, it says so:
FastAPI (Python) does not implement pg-boss (jobs stored in PostgreSQL) (--jobs pg-boss). It implements: bullmq, inngest, none.Stack packs describe how each app declares what it implements.
How is this guide?