Configuration through the environment

Configuration through the environment separates code from settings that vary by context (port, database URL, keys) by reading them from process.env. Values are strings that must be converted and validated at startup, and secrets are never committed to version control.

Example

const port = Number(process.env.PORT ?? 3000);

Related concepts

The whole glossary