Appearance
Environment Variables
All variables go in .env.local for local development and in your hosting provider's dashboard for production.
Required Variables
| Variable | Description | Example |
|---|---|---|
NEXTAUTH_URL | Your app's base URL | http://localhost:3000 |
NEXTAUTH_SECRET | JWT encryption key — 15+ random chars | abc123xyz789random |
MONGODB_URI | MongoDB Atlas connection string | mongodb+srv://user:pass@cluster.mongodb.net/db |
GOOGLE_ID | Google OAuth Client ID | 123456.apps.googleusercontent.com |
GOOGLE_SECRET | Google OAuth Client Secret | GOCSPX-abc123 |
RESEND_API_KEY | Resend email API key | re_abc123 |
STRIPE_PUBLIC_KEY | Stripe publishable key | pk_test_... or pk_live_... |
STRIPE_SECRET_KEY | Stripe secret key | sk_test_... or sk_live_... |
STRIPE_WEBHOOK_SECRET | Stripe webhook signing secret | whsec_... |
Optional Variables
| Variable | Description |
|---|---|
UPSTASH_REDIS_REST_URL | Upstash Redis URL for rate limiting |
UPSTASH_REDIS_REST_TOKEN | Upstash Redis token for rate limiting |
OPENAI_API_KEY | OpenAI API key (if using AI features) |
Local Setup
- Rename
.env.exampleto.env.local - Fill in each variable
- 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_tokenProduction Notes
NEXTAUTH_URLmust match your production domain exactly- Use
pk_live_andsk_live_Stripe keys in production (not test keys) .env.localis gitignored — set production variables in your hosting dashboard