Using Environment Variables
Environment variables let you manage app settings like DB URLs and secret keys without hardcoding them.
- Use the
dotenv
package to load variables from a.env
file - Access variables with
process.env
- Keep sensitive info out of version control
require('dotenv').config();
const dbUrl = process.env.DB_URL;