Environment variable
Definition
An environment variable is a named value provided to an application by the environment it runs in. Apps commonly use environment variables for database URLs, API keys, feature flags, and deployment-specific settings.
Why it matters
Environment variables keep configuration separate from code. This helps the same codebase run locally, on staging, and in production with different settings.
Example in VCA
In VCA, learners use environment variables to store values such as DATABASE_URL so a project can connect to the right database without exposing credentials in the code.
Another Real World Example
A hosted app might use one environment variable for its production database URL and a different value for its staging database URL.
Common mistakes
- Committing secret values to Git.
- Using a production value in local development by accident.
- Forgetting to set required variables in the hosting platform.
- Changing an environment variable without restarting the app when required.
- Using unclear names that make configuration hard to understand.