Skip to main content

Environment Variables

Environment variables let you manage different configurations for various deployment environments (development, staging, production) without changing your code.

Setting Your Environment

  1. Look at the top navigation bar
  2. Find the environment selector located next to the recent project selector
  3. Click on the environment dropdown to open the selection popup

Available Options

  • None: No environment selected (uses only local variables)
  • Development: Development environment variables
  • Staging: Staging environment variables
  • Production: Production environment variables
  • Custom: Any custom environments you've created

How Variables are Resolved

  • Local variables always override environment variables
  • Environment variables override default global variables
  • This ensures you can have environment-specific values while still allowing local overrides for testing

Creating Environment Files

Environment files should always start with .env followed by the environment name. For example:

  • .env → Global defaults shared across all environments
  • .env.dev → Development environment
  • .env.staging → Staging environment
  • .env.prod → Production environment

The base .env file acts as the global configuration, and environment-specific files override or extend these values.

Default Environment (.env)

API_BASE_URL=https://api.example.com
API_VERSION=v1
DB_HOST=localhost

Benefits of Using Environment Variables

AreaKey Benefits
Security• Keep sensitive data out of codebase
• Prevent accidental credential mixing
• No hardcoded secrets
Developer Experience• One-click environment switching
• Personal local overrides
• No manual configuration
Consistency• Same base config for all teams
• Identical structure across environments
• Reduce "works on my machine" issues
Rapid Switching• Test APIs in different environments
• Compare staging vs production instantly
• Validate environment features
Collaboration• Share base files via Git
• Keep overrides private
• Different local configs without conflicts
Organization• Clear environment separation
• Easy to track variable changes
• Simple to add new environments