Environment Variables Template
Example .env file for configuring local development and production environments.
Keeping configuration out of your codebase makes it easier to manage different environments and avoid leaking secrets. A .env
file contains key–value pairs that can be loaded into your application via tools like dotenv
. Here’s a template showing common patterns: API keys, database URLs, and runtime settings. Adjust and rename variables for your project.
# API configuration
API_URL=https://api.example.com
API_TOKEN=your-secret-token
# Database configuration
DATABASE_URL=postgres://user:password@localhost:5432/dbname
# Server settings
PORT=3000
NODE_ENV=development
# Feature flags
ENABLE_EXPERIMENTAL_FEATURE=false
Store this file outside your version control or add .env
to your .gitignore
. For production, use your deployment platform’s secret management instead of committed .env
files. Loading environment variables at runtime keeps your code flexible and secure.