Environment variables are used to configure your application without hardcoding values. You can access them in Node.js using process.env
. Libraries like dotenv
help manage them by loading variables from a .env
file. Example:
require('dotenv').config();
const dbPassword = process.env.DB_PASSWORD;
console.log(`Database Password: ${dbPassword}`);