Skip to content

Environment Variables

All variables go in .env.local for local development and in your hosting provider's dashboard for production.

Required Variables

VariableDescriptionExample
NEXTAUTH_URLYour app's base URLhttp://localhost:3000
NEXTAUTH_SECRETJWT encryption key — 15+ random charsabc123xyz789random
MONGODB_URIMongoDB Atlas connection stringmongodb+srv://user:pass@cluster.mongodb.net/db
GOOGLE_IDGoogle OAuth Client ID123456.apps.googleusercontent.com
GOOGLE_SECRETGoogle OAuth Client SecretGOCSPX-abc123
RESEND_API_KEYResend email API keyre_abc123
STRIPE_PUBLIC_KEYStripe publishable keypk_test_... or pk_live_...
STRIPE_SECRET_KEYStripe secret keysk_test_... or sk_live_...
STRIPE_WEBHOOK_SECRETStripe webhook signing secretwhsec_...

Optional Variables

VariableDescription
UPSTASH_REDIS_REST_URLUpstash Redis URL for rate limiting
UPSTASH_REDIS_REST_TOKENUpstash Redis token for rate limiting
OPENAI_API_KEYOpenAI API key (if using AI features)

Local Setup

  1. Rename .env.example to .env.local
  2. Fill in each variable
  3. Restart the dev server after changes: npm run dev

.env.local Template

bash
# Auth
NEXTAUTH_URL=http://localhost:3000
NEXTAUTH_SECRET=your-random-15-char-secret

# Database
MONGODB_URI=mongodb+srv://username:password@cluster.mongodb.net/dbname

# Google OAuth
GOOGLE_ID=your-google-client-id
GOOGLE_SECRET=your-google-client-secret

# Email
RESEND_API_KEY=re_your_api_key

# Stripe
STRIPE_PUBLIC_KEY=pk_test_your_key
STRIPE_SECRET_KEY=sk_test_your_key
STRIPE_WEBHOOK_SECRET=whsec_your_signing_secret

# Rate Limiting (optional)
UPSTASH_REDIS_REST_URL=https://your-db.upstash.io
UPSTASH_REDIS_REST_TOKEN=your_token

Production Notes

  • NEXTAUTH_URL must match your production domain exactly
  • Use pk_live_ and sk_live_ Stripe keys in production (not test keys)
  • .env.local is gitignored — set production variables in your hosting dashboard

See Also