If the file only contains non-sensitive data—such as pointing to http://localhost:8080 , local mock servers, or public sandbox API keys shared by the entire team—it is safe and recommended to commit it. It streamlines the onboarding process for new developers.
Understanding .env.development : The Definitive Guide to Managing Development Environments
Add the following patterns to your .gitignore file immediately when starting a project:
Historically, setting these variables required complex shell scripts or platform-specific system settings. The creation of the open-source dotenv library changed this by standardizing text files to load variables directly into an application process. The Dotenv Hierarchy .env.development
By convention, keys are always written in UPPER_CASE_SNAKE_CASE .
As projects grow, environment files can become cluttered. Keep them maintainable by grouping related configurations and utilizing comments.
| File Name | Purpose | Git Status | Load Conditions | |-----------|---------|------------|-----------------| | .env | Global default configuration for all environments | Commit (template values only) | Always loaded | | .env.local | Local overrides for all environments (except test) | (gitignored) | All environments except test | | .env.development | Development-specific defaults | Commit (safe defaults) | Development mode only | | .env.development.local | Local overrides for development only | Ignore (gitignored) | Highest priority in dev | | .env.production | Production-specific defaults | Commit (safe defaults) | Production mode only | | .env.test | Testing-specific configuration | Commit | Test mode only | If the file only contains non-sensitive data—such as
The root cause is often environmental mismatch.
: Many frameworks, such as React (Create React App) or Vite, automatically detect and load this file when you run a command like npm start or npm run dev . Common Example A typical .env.development file might look like this:
Tools like Doppler, HashiCorp Vault, and Infisical now sync to local .env.development files dynamically. Your .env.development becomes a symlink or a generated file that pulls from a cloud vault (but only for dev secrets). The creation of the open-source dotenv library changed
# .env.development REACT_APP_API_URL=http://localhost:5000/api REACT_APP_ENABLE_DEBUG=true DB_PASSWORD=secret_local_pw Use code with caution. 3. Consume the Variables
# Use "Sandbox" or "Test" keys here, never your production secrets
.env.development is a powerful tool for streamlining your development environment. By using a dedicated file for environment-specific variables, you can keep your development environment consistent, secure, and easy to manage. By following best practices and using .env.development effectively, you can take your development workflow to the next level.
Both tools have built-in support.