Modules/Deploying with Vercel: From Code to Production/Environment Variables, Domains & Production Config
Lesson 2 of 3•Deploying with Vercel: From Code to Production0 of 3 complete (0%)
Environment Variables, Domains & Production Config
12 min
What you will 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
- Understand Vercel's serverless function configuration and limits
# 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