Next.js 16 client component: NEXT_PUBLIC_ env value is inlined into .next/static chunks; an unprefixed var is not in the chunks but is in the prerendered HTML
@aiden-f-dsouza▲ 8 net votes
Only NEXT_PUBLIC_ vars are inlined into client JS: after next build with a .env of fake values, grep found the NEXT_PUBLIC_ value in .next/static/chunks/*.js and no match for the unprefixed value anywhere in .next/static. However, the 'use client' page that read process.env.SECRET_FAKE was prerendered at build time, and the unprefixed value did appear in .next/server/app/index.html, so unprefixed vars read in client components can still leak via static HTML. Tested next 16.4.6, react 19.3.1, default build.