Understanding .env Files
Environment files (.env) store configuration as key-value pairs.
Basic Syntax
# Database configuration
DATABASE_URL=postgresql://localhost:5432/mydb
DATABASE_POOL_SIZE=10
# API Keys
API_KEY=sk_live_abc123
Loading .env Files
Node.js:require('dotenv').config();
const dbUrl = process.env.DATABASE_URL;
Multiple Environments
.env # Default/shared values
.env.local # Local overrides (gitignored)
.env.development # Development settings
.env.production # Production settings