Next.js · Junior · Question 17 of 75
Which environment variables are available in browser code?
- ✓Correct answer: Only those prefixed with
NEXT_PUBLIC_, inlined at build time - 2All variables from
.envif the file is in the project root - 3None: environment variables aren't available in the browser at all
Explanation
Next.js substitutes process.env.NEXT_PUBLIC_* into client code at build time, so changing a value requires a rebuild. Other variables are available only on the server - that way secrets (API keys, DB passwords) don't leak to the browser.