nextjsboilerplate Docs
Deployment

Environment variables reference

Every env var the boilerplate reads, what it does, and what happens when it is unset.

Convention

Every external provider is optional and degrades gracefully. There is no required external service for local dev. In production, you set the keys for the providers you actually use; the rest no-op without breaking the app.

The full canonical list lives in .env.example at the repo root. The summary below is grouped by subsystem.

Database

VarRequiredDefaultBehavior when unset
DATABASE_URLProduction yes(PGlite local)Local dev uses PGlite on localhost:5433.

Auth

VarRequiredDefaultBehavior when unset
NEXTAUTH_SECRETProduction yesSessions can't be signed. Sign-in fails.
NEXTAUTH_URLProduction yeshttp://localhost:3000OAuth callbacks build wrong URLs.
GITHUB_CLIENT_ID / GITHUB_CLIENT_SECRETNoGitHub OAuth button hides.
GOOGLE_CLIENT_ID / GOOGLE_CLIENT_SECRETNoGoogle OAuth button hides.

Email (Resend)

VarRequiredDefaultBehavior when unset
RESEND_API_KEYNoEmail.* calls log HTML to stdout instead of sending.
EMAIL_FROMNono-reply@example.com
EMAIL_FROM_NAMENoNext.js BoilerplateUsed as sender display + brand in templates.

Stripe

VarRequiredDefaultBehavior when unset
STRIPE_SECRET_KEYNoCheckout dispatch fails; buttons stay visible.
STRIPE_WEBHOOK_SECRETNoWebhook handler 200s without firing audit events (dev safety).
NEXT_PUBLIC_STRIPE_PUBLISHABLE_KEYNoStripe.js can't init client-side.
STRIPE_PRICE_PRO_MONTHLY etc.Per-tierSubscription sign-ups for that tier no-op.

See architecture/billing for the full webhook flow.

LLM providers

VarRequiredDefaultBehavior when unset
ANTHROPIC_API_KEYNoClaude calls throw LlmProviderKeyMissing.
OPENAI_API_KEYNoGPT calls throw LlmProviderKeyMissing.
OLLAMA_BASE_URLNoLocal LLM calls throw same error.

The visible-error contract per repo rules — no silent fallback, the missing env var name is in the error.

Storage

VarRequiredDefaultBehavior when unset
STORAGE_PROVIDERNolocalRGPD exports + uploads write to ./local-storage/.
STORAGE_S3_*If STORAGE_PROVIDER=s3Uploads fail with explicit error.
STORAGE_R2_*If STORAGE_PROVIDER=r2Same as above.

Observability

VarRequiredDefaultBehavior when unset
NEXT_PUBLIC_SENTRY_DSN / SENTRY_AUTH_TOKENNoSentry no-ops; no source map upload.
NEXT_PUBLIC_SENTRY_DISABLEDNoSet to disable Sentry entirely (CI / preview).
NEXT_PUBLIC_POSTHOG_KEY / NEXT_PUBLIC_POSTHOG_HOSTNoPostHog client no-ops.
ARCJET_KEYNoBot detection middleware short-circuits.

Security headers

VarRequiredDefaultBehavior when unset
SECURITY_CONTACT_EMAILNosecurity@example.comUsed in /.well-known/security.txt.
SECURITY_POLICY_URLNo${origin}/security-policy

Maintenance mode

VarRequiredDefaultBehavior when unset
MAINTENANCE_MODENo0When 1, every route except allow-list redirects to /maintenance.
MAINTENANCE_ETANoFree-form string shown on /maintenance.
MAINTENANCE_STATUS_URLNoLink from /maintenance to status page.
MAINTENANCE_CHANGELOG_URLNoLink from /maintenance to "what changed".

Jobs

VarRequiredDefaultBehavior when unset
JOBS_PROVIDERNolocalUses the in-process local job bus. For production workers, choose railway, cloudflare-queues, or trigger.
RAILWAY_WORKER_URL / RAILWAY_WORKER_TOKENRequired when JOBS_PROVIDER=railwayRailway dispatch throws a visible configuration error instead of dropping jobs.
CLOUDFLARE_QUEUE_PRODUCER_URLRequired when JOBS_PROVIDER=cloudflare-queuesCloudflare queue dispatch throws a visible configuration error.
TRIGGER_API_KEY / TRIGGER_PROJECT_IDRequired when JOBS_PROVIDER=triggerTrigger.dev dispatch throws a visible configuration error.

How to verify your setup

# Print every env var the app actually reads at boot.
# (Drops to stderr in dev so you can pipe it.)
NEXT_DEV_ENV_DUMP=1 npm run dev

The Env.ts library validates every var at boot using zod. A misconfigured var fails fast with a typed error pointing at the var name and expected shape.

Anti-pattern: .env.production

Don't commit .env.production to the repo. Vercel / Cloudflare / Fly all provide an env-var dashboard. The repo only ever sees .env.example (committed) and .env.local (gitignored, dev only).

On this page