The .env.development file is an environment-specific configuration file used to store variables—such as API keys, database URLs, and feature flags—that should only be active during local development. Core Purpose & Usage
Targeted Configuration: While a standard .env file usually contains shared defaults, .env.development is specifically loaded when your development server is running (e.g., via npm start or vite). .env.development
Separation of Concerns: It allows you to use a local "sandbox" database or a mock API endpoint without accidentally pointing to production data. API_URL=http://localhost:3000 DEV_EMAIL=admin@localhost
Automatic Loading: Modern frameworks like Vite, Next.js, and Create React App automatically detect and prioritize this file when NODE_ENV is set to development. Essential Best Practices Guides: Environment Variables - Next.js The Hierarchy Most modern frameworks (React with Vite,
.env.development:API_URL=http://localhost:3000DEV_EMAIL=admin@localhost.comMOCK_STRIPE_KEY=pk_test_xyz (Test keys are fine)DEBUG=trueMost modern frameworks (React with Vite, Next.js, Vue, Node.js with dotenv, Django, Laravel, etc.) support the following file precedence:
.env – The fallback. Contains default settings..env.development – Loaded only when NODE_ENV=development..env.production – Loaded only when NODE_ENV=production..env.local – (Often gitignored) For local overrides.In Node.js, process.env is mutated at startup. If you change .env.development while the server is running, the app won't see the changes. Always restart your dev server after editing environment files.
If you store production AWS keys in a .env file that you accidentally commit to GitHub, bots will find them within minutes. .env.development is rarely committed (but can be, if it contains only harmless dev defaults).