📄.env File
Also known as .env, dotenv, Environment File
Secret keys and passwords in a file. It stays out of the code and Git.
Think of it like
Think of it like a locked note of house keys. Your app reads it, but you never show it to anyone.
Example
Jack keeps his payment key in .env. His laptop uses a test key, and the live server has the real one in its own .env.
Why it matters
Secrets in code end up in Git. Then anyone with the repo can find them.
Definition
Example code
ini
DATABASE_URL=postgres://localhost:5432/shop
API_KEY=test_123Common mistake
Key takeaways
- 1Name equals value. One setting per line.
- 2Secrets stay out. Keys never sit in the code.
- 3Never committed. Always list it in .gitignore.