Environment variables
All configuration lives in .env.local (copied from .env.example). The keys
present in your file depend on the features you selected at scaffold time — the
scaffolder only writes the vars your build uses.
NEXT_PUBLIC_-prefixed vars are exposed to the browser. Everything else is
server-only. Restart the dev server after changing any env var.
Core (always present)
| Variable | Required | Description |
|---|---|---|
DATABASE_URL | ✅ | Postgres connection string. Hosted providers usually need ?sslmode=require. |
TEST_DATABASE_URL | for tests | Separate DB for integration tests. |
BETTER_AUTH_SECRET | ✅ | 32-byte secret. Generate with openssl rand -base64 32. |
BETTER_AUTH_URL | ✅ | Server-side base URL, e.g. http://localhost:3000. |
NEXT_PUBLIC_BETTER_AUTH_URL | ✅ | Same URL, exposed to the browser auth client. |
EMAIL_PROVIDER | ✅ | console (dev default — prints emails to stdout) or resend. |
AI
| Variable | Description |
|---|---|
AI_PROVIDER | Which provider backs chat. See AI providers. |
AI_MODEL | Model id for that provider. Provider default is used if omitted. |
OPENAI_API_KEY (etc.) | Only the key for your selected provider is required. |
Billing (Stripe)
| Variable | Description |
|---|---|
BILLING_PROVIDER | stripe. |
NEXT_PUBLIC_BILLING_PROVIDER | stripe (browser-visible). |
STRIPE_SECRET_KEY | Your Stripe secret key (sk_…). |
STRIPE_WEBHOOK_SECRET | whsec_… from stripe listen (dev) or the dashboard webhook (prod). |
STRIPE_PRICE_PRO | Price id (price_…) for the Pro plan. |
STRIPE_PRICE_TEAM | Price id (price_…) for the Team plan. |
Email (Resend)
Only used when EMAIL_PROVIDER=resend.
| Variable | Description |
|---|---|
RESEND_API_KEY | Resend API key. |
EMAIL_FROM | From address, e.g. StackBlaze <onboarding@resend.dev>. |
Rate limiting (Upstash Redis)
Optional. When unset, AI-route rate limiting is a no-op — the app runs fine without it.
| Variable | Description |
|---|---|
UPSTASH_REDIS_REST_URL | From the Upstash console (REST API section). |
UPSTASH_REDIS_REST_TOKEN | REST token. |
OAuth providers (optional)
A login button appears only when both the id and secret for a provider are set.
| Variable | Description |
|---|---|
GOOGLE_CLIENT_ID / GOOGLE_CLIENT_SECRET | Google OAuth app. |
GITHUB_CLIENT_ID / GITHUB_CLIENT_SECRET | GitHub OAuth app. |
Register these callback URLs with each provider:
${BETTER_AUTH_URL}/api/auth/callback/google
${BETTER_AUTH_URL}/api/auth/callback/githubIn production, set BETTER_AUTH_URL / NEXT_PUBLIC_BETTER_AUTH_URL to your
real domain and re-register OAuth callback URLs to match — otherwise logins
redirect to localhost.