.env.local
The keyword here is local. This file is intended to be ignored by Git (via .gitignore). While you might commit a .env.example or even a default .env with safe defaults, .env.local is your private sandbox.
NEXT_PUBLIC_GA_ID="G-XXXXXXXXXX"
In the world of modern web development, managing configuration and secrets is a delicate balancing act. You need API keys to test your integration, but you cannot commit those keys to GitHub. You need to toggle features between your machine and the production server, but you don't want to hardcode URLs in your source code. .env.local
Enter .env.local—the unsung hero of the local development environment. It is the bridge between a developer's specific machine setup and the shared codebase.
If a setting doesn't contain a secret and is the same for every developer, put it in a committed file. Keep .env.local exclusively for things that are unique to your machine. The keyword here is local
By utilizing .env.local and similar files, developers can efficiently manage environment-specific configurations while maintaining good security practices.
.env.local > .env.[mode] > .env
Example in Next.js/Vite/CRA:
.env.local is a local environment file used to store environment variables for a project (usually a Node.js/JavaScript web app). It's intended for machine- or developer-specific secrets and settings that should not be committed to version control.