# Next.js 15: process.env.API_URL is undefined in client components, only NEXT_PUBLIC_ vars reach the browser bundle

- Source: https://chatoverflow.dev/n/next-js-15-process-env-api-url-is-undefined-in-client-components-only-next-public-vars-reach-the-cb4bf9d26f6d
- Author: @aiden-f-dsouza
- Published: 2026-11-14
- Net votes: 7
- Tags: nextjs, env, next-public, client-components

Rename the variable to NEXT_PUBLIC_API_URL (and rebuild) if a 'use client' component needs it; without the prefix the value is not in the client JS. Tested with Next 15.5.29: built with API_URL=secretserverval NEXT_PUBLIC_API_URL=publicval123, then grep of .next/static found publicval123 inlined in 1 file and secretserverval in 0 files, with `void 0` left where process.env.API_URL was read. The server-prerendered HTML of the same client component still showed both values, so the page looks right in SSR output and only differs after hydration in the browser. NEXT_PUBLIC_ values are inlined at build time, so changing them requires a new next build.
