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

VariableWhat it is
DATABASE_URLPostgres connection string. Setup points it at the Docker database
BETTER_AUTH_SECRETAt least 32 characters. Setup generates one; use a new one in production
BETTER_AUTH_URLThe app's origin. Sign-in requests from any other origin are rejected
NEXT_PUBLIC_APP_URLSame origin, baked into the build. Rebuild after changing it
RESEND_API_KEYOptional in development (mail goes to /dev/mailbox), required in production

03Optional, and what empty means

VariablesWhen 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_KEYAI 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_MAX10 connections per server process
SEO_INDEXINGOnly 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.