Next.js · Senior · Question 61 of 75
publicRuntimeConfig was removed in Next.js 16. How do you provide config that differs per environment without rebuilding?
- ✓Correct answer: Read server-side environment variables at request time and pass the needed values to client components
- 2Use
NEXT_PUBLIC_variables - they're read at runtime - 3Put the config into
public/config.jsand edit it in the bundle
Explanation
NEXT_PUBLIC_ values are inlined at build time. Reading process.env in a dynamically rendered server component (e.g. after connection()) picks up the deploy's runtime values.