Environment Variables
Environment variables store config and secrets (API keys, database URLs) outside your code. Node reads them from process.env. Keep them in a .env file and add .env to .gitignore so secrets never reach GitHub.
# .env PORT=3000 DATABASE_URL=postgres://user:pass@localhost:5432/app // server.js (Node 20+ can load .env with --env-file) // node --env-file=.env server.js const port = process.env.PORT || 3000 console.log(process.env.DATABASE_URL) # .gitignore .env