Vercel Environment Variables Matrix
This document provides a complete reference for setting environment variables in Vercel across different deployment environments.
For deployment agents A7, A8, A9, A11: Use this matrix to configure Vercel environment variables correctly.
Environment Scopes
Vercel supports three environment scopes:
- Production: Live production deployment
- Preview: PR/branch preview deployments
- Development: Local development (pulled via
vercel env pull)
Required Variables (Production)
These MUST be set in Vercel for production deployments to succeed.
| Variable | Scope | Value Source | Notes for Deployment Agents |
|---|
NEXT_PUBLIC_SUPABASE_URL | Production, Preview, Development | Supabase Dashboard | Use production Supabase for prod, staging for preview |
NEXT_PUBLIC_SUPABASE_ANON_KEY | Production, Preview, Development | Supabase Dashboard | Match the environment (prod/staging) |
SUPABASE_SERVICE_ROLE_KEY | Production, Preview, Development | Supabase Dashboard | SECRET - Use different keys per environment |
DATABASE_URL | Production, Preview, Development | Supabase Dashboard → Database | Use connection pooler URL for serverless |
NEXT_PUBLIC_SITE_URL | Production | https://app.petunia.gardenpatch.xyz | Update to actual production domain |
NEXT_PUBLIC_SITE_URL | Preview | https://$VERCEL_URL | Automatic preview URL |
NEXT_PUBLIC_SITE_URL | Development | http://localhost:3000 | Local development URL |
SESSION_SECRET | Production, Preview, Development | Generate with openssl rand -base64 32 | SECRET - Different per environment |
Optional Variables (Feature-Specific)
Set these only if the corresponding feature is enabled.
Yelp Integration
| Variable | Scope | Required If | Notes |
|---|
YELP_API_KEY | Production, Preview | Yelp integration enabled | SECRET |
YELP_CLIENT_ID | Production, Preview | Yelp OAuth enabled | |
YELP_CLIENT_SECRET | Production, Preview | Yelp OAuth enabled | SECRET |
Google Integration
| Variable | Scope | Required If | Notes |
|---|
GOOGLE_CLIENT_ID | Production, Preview | Google OAuth enabled | |
GOOGLE_CLIENT_SECRET | Production, Preview | Google OAuth enabled | SECRET |
GOOGLE_API_KEY | Production, Preview | Google Business Profile enabled | SECRET |
Facebook Integration
| Variable | Scope | Required If | Notes |
|---|
FACEBOOK_CLIENT_ID | Production, Preview | Facebook integration enabled | |
FACEBOOK_CLIENT_SECRET | Production, Preview | Facebook integration enabled | SECRET |
AI Services
| Variable | Scope | Required If | Notes |
|---|
OPENAI_API_KEY | Production, Preview | OpenAI features enabled | SECRET - Monitor usage |
ANTHROPIC_API_KEY | Production, Preview | Claude features enabled | SECRET - Monitor usage |
PINECONE_API_KEY | Production, Preview | Vector search enabled | SECRET |
Voice Services
| Variable | Scope | Required If | Notes |
|---|
ELEVENLABS_API_KEY | Production, Preview | ElevenLabs TTS enabled | SECRET |
CARTESIA_API_KEY | Production, Preview | Cartesia voice enabled | SECRET |
RETELL_API_KEY | Production, Preview | Retell voice enabled | SECRET |
CARTESIA_VOICE_ID | Production, Preview | Cartesia voice enabled | Voice ID from Cartesia dashboard |
NEXT_PUBLIC_RETELL_AGENT_ID | Production, Preview | Retell voice enabled | Agent ID from Retell dashboard |
Payments (Stripe)
| Variable | Scope | Required If | Notes |
|---|
STRIPE_SECRET_KEY | Production | Billing enabled | SECRET - Use live key |
STRIPE_SECRET_KEY | Preview | Billing enabled | SECRET - Use test key |
STRIPE_PUBLISHABLE_KEY | Production | Billing enabled | Use live key |
STRIPE_PUBLISHABLE_KEY | Preview | Billing enabled | Use test key |
STRIPE_WEBHOOK_SECRET | Production | Stripe webhooks enabled | SECRET - From Stripe webhook settings |
Email
| Variable | Scope | Required If | Notes |
|---|
MAILGUN_API_KEY | Production, Preview | Mailgun email enabled | SECRET |
MAILGUN_DOMAIN | Production, Preview | Mailgun email enabled | Your sending domain |
MAILGUN_REGION | Production, Preview | Mailgun email enabled | eu or us (default: eu) |
SMTP_HOST | Production, Preview | SMTP email enabled | |
SMTP_PORT | Production, Preview | SMTP email enabled | Usually 587 or 465 |
SMTP_USER | Production, Preview | SMTP email enabled | |
SMTP_PASSWORD | Production, Preview | SMTP email enabled | SECRET |
SMS (Twilio)
| Variable | Scope | Required If | Notes |
|---|
TWILIO_ACCOUNT_SID | Production, Preview | Twilio SMS enabled | |
TWILIO_AUTH_TOKEN | Production, Preview | Twilio SMS enabled | SECRET |
TWILIO_PHONE_NUMBER | Production, Preview | Twilio SMS enabled | E.164 format |
Monitoring
| Variable | Scope | Required If | Notes |
|---|
SENTRY_DSN | Production, Preview | Sentry monitoring enabled | |
SENTRY_AUTH_TOKEN | Production | Sentry releases enabled | SECRET |
Redis/Caching
| Variable | Scope | Required If | Notes |
|---|
UPSTASH_REDIS_REST_URL | Production, Preview | Redis caching enabled | Upstash dashboard |
UPSTASH_REDIS_REST_TOKEN | Production, Preview | Redis caching enabled | SECRET |
RATE_LIMIT_REDIS_URL | Production, Preview | Rate limiting enabled | Redis connection string |
Security
| Variable | Scope | Required If | Notes |
|---|
CSRF_SECRET | Production, Preview | CSRF protection enabled | SECRET - 32+ chars |
WEBSOCKET_ENCRYPTION_KEY | Production, Preview | WebSocket encryption enabled | SECRET - 32+ chars |
Deployment Agent Instructions
For A7 (Production Deployment)
- Set ALL required variables in Vercel → Settings → Environment Variables
- Set scope to "Production" for production-only values
- Set scope to "Production, Preview, Development" for shared values
- Verify all SECRET variables are properly hidden
- Test deployment with
vercel --prod
For A8 (Staging Deployment)
- Use "Preview" scope for staging-specific variables
- Use test/staging keys for third-party services (Stripe test mode, etc.)
- Use staging Supabase project
- Test with preview deployment
For A9 (Feature Branch Deployment)
- Use "Preview" scope for branch deployments
- Consider using demo services for expensive APIs (AI, Voice)
- Use minimal feature flags
For A11 (Rollback Deployment)
- Ensure environment variables are versioned in 1Password/Vault
- Have backup of all production environment variables
- Test rollback in preview environment first
Verification Checklist
Before deploying, verify:
Troubleshooting
Build fails with "Missing required variable"
Check Vercel build logs for the specific variable. Add it to Vercel environment variables with correct scope.
Runtime error: "Invalid Supabase URL"
Verify NEXT_PUBLIC_SUPABASE_URL is set for the correct environment (Production/Preview).
500 errors after deployment
Check Vercel function logs. Often caused by missing DATABASE_URL or service role keys.
Webhooks not working
Verify webhook secrets match Vercel deployment URL. Update webhook URLs in third-party services (Stripe, etc.).
Security Notes
- Never commit .env files with real values to git
- Use Vercel's built-in secrets management - values are encrypted at rest
- Rotate secrets regularly - see ENV_GUIDE.md for rotation schedule
- Use different keys per environment - never share production keys with staging
- Monitor for leaked secrets - enable GitHub secret scanning
For questions about Vercel deployment:
- Vercel configuration: Platform Team
- Environment variable issues: See ENV_GUIDE.md for variable owners
- Deployment failures: Check Vercel logs first, then contact Platform Team