Environment Configuration
Set up and manage multiple environments for your Echo application
Overview
Three environments
Development
Local development on your machine
Preview
Automatic deployments from branches
Production
Live production environment
Development Environment
Local development setup
Configure your local environment using .env.local:
Running Locally
Preview Environment
Vercel preview deployments
Preview deployments are automatically created for each branch. Configure environment variables in Vercel:
- Go to your Vercel project settings
- Navigate to Environment Variables
- Add variables for Preview environment
- Use preview-specific values (e.g., preview database, test API keys)
Note:
Vercel automatically provides VERCEL_URL for preview deployments. You can use this in your environment variables.
Production Environment
Live production setup
Configure production environment variables in Vercel:
- Go to your Vercel project settings
- Navigate to Environment Variables
- Add variables for Production environment
- Use production values (production database, live API keys)
Environment Variables by Type
Organize your variables
Public Variables
Variables prefixed with NEXT_PUBLIC_ are exposed to the browser:
- •
NEXT_PUBLIC_APP_URL - •
NEXT_PUBLIC_SUPABASE_URL - •
NEXT_PUBLIC_SUPABASE_ANON_KEY
Server Variables
Server-only variables (never exposed to the browser):
- •
BETTER_AUTH_SECRET - •
POSTGRES_URL - •
STRIPE_SECRET_KEY - •
RESEND_API_KEY
Best Practices
Environment management tips
- Use different databases: Separate databases for development, preview, and production
- Use Stripe test mode: Always use test mode for development and preview environments
- Keep secrets secure: Never commit
.env.localto version control - Use Vercel CLI: Pull environment variables locally with
vercel env pull - Validate variables: Use the
npm run check:envscript to validate your environment
Troubleshooting
Common issues
Variables not updating
After updating environment variables in Vercel, redeploy your application for changes to take effect.
Wrong environment detected
Ensure APP_ENV is set correctly for each environment (development, preview, production).
Database connection errors
Verify that POSTGRES_URL or SUPABASE_DB_URL is set correctly for each environment.