Build-time vs runtime
| Variable kind | Read when? |
|---|---|
NEXT_PUBLIC_* | Build time — baked into the bundle |
| Server-only | Runtime — read on every request |
The Docker problem
Building one image and deploying it to staging + production with different settings? NEXT_PUBLIC_* values can't change between environments — they're already baked in. You either rebuild per environment or use runtime config strategies (e.g., proxy injects them, or you read from server only).
Loading order
- Already-set
process.env .env.production.local/.env.development.local.env.local(skipped in test).env.production/.env.development.env