Introduction
- Text file that stores env vars (vars provided to app by OS / runtime).
- Key=value pairs.
- Used to store config + secrets
It help to make
- Secrets stay outside code (no leak)
- Different values for:
- Same code, different behavior
How it works
Node.js / Frontend (Vite, Next.js)
They use a library like dotenv
- Read .env
- Put values into process.env
- Your app access the env var
Docker & Docker Compose
- Reads .env
- Injects variables into the container