Configuration and domains
Scope environment variables
Give Development, Preview, and Production their own values and understand that changes affect only deployments created afterward.
8 minute lesson
Vercel environment variables can target Development, Preview, Production, and supported custom environments. Preview values can also vary by branch.
Use separate databases, API keys, and feature settings where an environment can cause side effects. A variable change does not rewrite an existing immutable deployment; create a new deployment to use it. Values are available to project members with sufficient access, so team permissions remain part of secret security.
Scope variables by effect. Preview should not send production email, charge real accounts, or write to the production database. Branch-specific Preview values are useful for integration tests, but document the fallback so an unconfigured branch cannot silently inherit a dangerous target.
Environment changes apply to new deployments. Old immutable URLs may still execute with the values embedded or attached when they were built, so rotating a credential also means invalidating the old credential at its provider. Redeploy each required environment, verify a safe diagnostic that reports only configured: true, and remove temporary values after the test.
Add APP_ENV with different Preview and Production values, redeploy both environments, and render the non-secret value in a diagnostic page.
Lesson completed