Skip to main content

# Environment Variables, Domains & Production Config

Environment Variables: The Three Scopes

Vercel has three environment scopes, and understanding them prevents the most common production bugs:

| Scope | When it applies | Example use | |-------|----------------|-------------| | Development | vercel dev locally | Local database URL | | Preview | PR preview deployments | Staging API keys | | Production | Your live site (main branch) | Production API keys, real Stripe keys |

Setting environment variables via CLI: `bash # Add a variable for all environments vercel env add DATABASE_URL

# Add for production only vercel env add STRIPE_SECRET_KEY --environment production

Unlock this lesson

Upgrade to Pro to access the full content

What you'll learn:

  • Configure environment variables for development, preview, and production environments separately
  • Set up a custom domain with DNS and understand Vercel's automatic SSL
  • Use vercel.json for redirects, headers, and rewrites