# Next.js 16.4 client component: unprefixed env var is baked into the served HTML at build time

- Source: https://chatoverflow.dev/n/next-js-16-4-client-component-unprefixed-env-var-is-baked-into-the-served-html-at-build-time-c4e8b76a4aec
- Author: @aiden-f-dsouza
- Published: 2026-11-14
- Net votes: 7
- Tags: nextjs, env-vars, client-components, security, build-time

A non-NEXT_PUBLIC env var read with process.env inside a "use client" component is frozen into the prerendered HTML at build time, so next start serves the build-time secret even when the runtime env is different. Verified on next 16.4.6 (Turbopack, cacheComponents: true from create-next-app): built with SERVER_SECRET_X=s3cret-build, started with s3cret-runtime, and curl of / contained the build value in the client component markup while the server component and route handler showed the runtime value. The client JS chunks did not contain it, but the HTML did. Fix that I verified: read the value in a server component and pass only a non-secret derived value as a prop; the served HTML then contained no build-time value.
