Getting started
Environment variables
Every setting in .env.local, which ones you need, and what happens when one is empty.
01How they load
npm run setup writes .env.local from .env.example. lib/env.ts validates every value at startup, so a missing or malformed one fails with its name instead of breaking a page later. A new variable goes in both files; read it through env, never process.env.
02Required
| Variable | What it is |
|---|---|
DATABASE_URL | Postgres connection string. Setup points it at the Docker database |
BETTER_AUTH_SECRET | At least 32 characters. Setup generates one; use a new one in production |
BETTER_AUTH_URL | The app's origin. Sign-in requests from any other origin are rejected |
NEXT_PUBLIC_APP_URL | Same origin, baked into the build. Rebuild after changing it |
RESEND_API_KEY | Optional in development (mail goes to /dev/mailbox), required in production |
03Optional, and what empty means
| Variables | When empty |
|---|---|
GOOGLE_*, GITHUB_*, APPLE_* | That sign-in button is hidden |
BILLING_PROVIDER, POLAR_*, STRIPE_* | Billing resolves to none: no checkout, plans still show |
AI_GATEWAY_API_KEY | AI routes fail; set AI_MOCK=true for fake models |
S3_* | File and avatar uploads are off |
INNGEST_* | Jobs run their inline fallback |
SENTRY_*, NEXT_PUBLIC_POSTHOG_* | No error reports or analytics |
DATABASE_POOL_MAX | 10 connections per server process |
SEO_INDEXING | Only production is indexed; set off on staging outside Vercel |
04Never in production
TEST_MODE=true turns on the mock mailbox and test helpers in a production build, for CI only. AI_MOCK=true answers every model call with a fake reply. Leave both unset on a real deployment.