.env.development |top| Instant
Create config.js :
# .env.development API_URL=http://localhost:3000 DEBUG=true SECRET_KEY=dev_secret_123 # never reuse production secrets PORT=4000
: Keep your production credentials safe by using separate files like .env.production . .env.development
The structure is intentionally simple and human-readable. A typical .env.development file might look like this:
to define variables that differ from your production or testing environments. Common examples include: : Points to a local or staging server (e.g., API_BASE_URL=http://localhost:5000 Feature Flags : Enables experimental features only for developers (e.g., ENABLE_NEW_DASHBOARD=true Debug Modes : Controls the verbosity of logs. Stack Overflow 2. Configure the File Create a file named .env.development in your project's root directory. For frameworks like Create React App Create config
# Security Settings JWT_SECRET=your_jwt_secret_here CORS_ORIGIN=http://localhost:3000
Run your app:
Ensure you prefixed the key correctly if your framework requires it (e.g., VITE_ or NEXT_PUBLIC_ ).
This couples your environment logic to your source code. With .env.development , the code simply reads process.env.API_URL —the file decides the value. Common examples include: : Points to a local
GITHUB_ID=your_dev_client_id GITHUB_SECRET=your_dev_client_secret # --- FEATURE FLAGS --- # Toggle features during development without changing code ENABLE_NEW_DASHBOARD=true SHOW_DEBUG_CONSOLE=true Use code with caution. Copied to clipboard Essential Best Practices : Never commit this file to your repository. Add .env.development .gitignore to prevent leaking local passwords or test keys.
1. .env.development.local (Highest Priority: Machine-specific local overrides) 2. .env.development (Environment-specific: Tracked settings for team development) 3. .env.local (Global Local: Applies to all environments except 'test') 4. .env (Lowest Priority: Default fallback settings) The Role of .env.development.local