env.inspector
Next.js 16 · App Router · JavaScript

Your .envfile doesn't keep secrets. Where the code runs does.

Ten small, deliberately broken (and fixed) Next.js routes that show exactly how environment variables move between your server, your build, and the browser — and how to check, yourself, what actually ended up in front of a visitor.

NEXT_PUBLIC_SITE_NAMEPublic
undefined

Rendered by a Server Component, but safe: it was always meant to reach the browser. Inspect this page's source — you'll find it in the HTML and in the JS bundle.

DATABASE_URLServer-only · masked
undefined

This Server Component CAN read the full value — but we're deliberately only printing a masked preview. Problem 01 shows what happens the moment you print the real thing into HTML.

Legend

Public

Intentionally shipped to every visitor's browser.

Concept

Background you need before the danger cases make sense.

Caution

Works, but has sharp edges (limits, freshness, scope).

Danger

A pattern that leaks or can easily leak a secret.

The ten problems

each has notes, a live demo, and a self-check
⚠Before you deploy this yourself
Every "secret" in this repo is a fake demo value (see .env.local.example). The project also ships a real automated check — npm run verify — that builds the app and greps the client bundle for a marker string, so you can confirm nothing server-only made it into .next/static before you ever push to Vercel.