Loading Depth Study
Preparing your workspace
Configuration controls how software behaves in different environments, while environment variables provide external values to running applications.
The same application may run locally, in testing, and in production with different databases, API URLs, ports, or service credentials. Keeping these values outside the main source code makes the application easier to configure and safer to manage. Environment variables are commonly provided by the operating system, shell, hosting platform, or development tools.
A web application can use one database URL locally and a different database URL in production without changing the source code.
const port = process.env.PORT || 3000; const databaseUrl = process.env.DATABASE_URL; console.log(port);
The application reads configuration from the environment and falls back to port 3000 when PORT is not provided.