But on your local machine, you need to trace a deep bug:
# .env.example (committed to the repository) REACT_APP_API_BASE_URL= REACT_APP_GOOGLE_MAPS_API_KEY= DATABASE_URL=postgresql://user:password@localhost/db NEXT_PUBLIC_ANALYTICS_ID=
File names starting with a dot ( . ) are hidden on Unix/Mac. On Windows, they work fine, but Git Bash or PowerShell may hide them by default. Use ls -Force or dir /a . .env.development.local
The correct pattern for ignoring these files in .gitignore is .env*.local . This pattern matches .env.local , .env.development.local , and any other future .env.*.local files. For example:
Remember: commit the shared .env.development , ignore the local .env.development.local , and always respect the load order. Do this, and you will never again have the dreaded "but it works on my machine" argument over environment variables. But on your local machine, you need to trace a deep bug: #
The hierarchy shifts because the target environment is production:
has been updated with any new keys you added to your local file so other team members know they need to provide their own values. Use ls -Force or dir /a
Each developer then copies this file to create their own .env.development.local :
You should commit secret keys to a public or private Git repository. Because .env.development.local is intended to be ignored by Git, it is the safest place to put your personal API keys while testing code locally. 2. Tailoring to Your Local Machine (Personalization)
), frameworks typically load files in this order, with later files overriding earlier ones: (Default/Fallback) .env.development (Shared dev defaults) .env.local (General local overrides) .env.development.local (Specific local dev overrides) Review Checklist Git Status : Confirm the file is not tracked by Git. Run git check-ignore .env.development.local to verify. Sensitive Data
"scripts": "dev": "NODE_ENV=development next dev", "dev:staging": "NODE_ENV=staging next dev", "build:prod": "NODE_ENV=production next build"