Skip to main content
GoodFirstPicks
DashboardIssuesReposLeaderboard

GoodFirstPicks by Leaveitblank © 2026

CreatorRequest a RepoPrivacy PolicyTerms of Service
Non-public env var exposed client-side | GoodFirstPicks

Non-public env var exposed client-side

vercel/next.js 6 comments 11d ago
View on GitHub
mediumopenScope: somewhat clearSkill match: maybeNext.jsTypeScriptReact

Why this is a good first issue

Non-public env vars are being exposed client-side contrary to documentation.

AI Summary

The issue reports that non-public environment variables (without NEXT_PUBLIC_ prefix) are being exposed client-side in the document response, which contradicts Next.js documentation. This appears to be a framework-level behavior that needs investigation and potential modification. The main blocker is determining whether this is intentional behavior or a bug.

Issue Description

Link to the code that reproduces this issue

https://github.com/joostmeijles/nextjs-private-env-var-exposed

To Reproduce

  1. Create client-side React component with property, see ClientComponent.tsx
  2. Use the component in a page and pass a non-public env variable, see page.tsx
  3. Set env var SECRET to "my-secret"
  4. Build the application
  5. Start the application (or go to https://nextjs-private-env-var-exposed.vercel.app/)
  6. Inspect the document response and notice that it contains "my-secret"

Current vs. Expected behavior

The non-public environment variable "SECRET" is exposed in the client-side document.

Expectation is that only environment variables prefixed with "NEXT_PUBLIC" should be exposed client-side.

Provide environment information

Operating System:
  Platform: win32
  Arch: x64
  Version: Windows 11 Pro
  Available memory (MB): 32472
  Available CPU cores: 16
Binaries:
  Node: 22.16.0
  npm: 10.9.2
  Yarn: 1.22.19
  pnpm: 10.12.1
Relevant Packages:
  next: 15.5.1-canary.11 // Latest available version is detected (15.5.1-canary.11).
  eslint-config-next: N/A
  react: 19.1.1
  react-dom: 19.1.1
  typescript: 5.9.2
Next.js Config:
  output: N/A

Which area(s) are affected? (Select all that apply)

Not sure

Which stage(s) are affected? (Select all that apply)

Vercel (Deployed), next build (local)

Additional context

No response

Want to work on this?

Claim this issue to let others know you're working on it. You'll earn 20 points when you complete it!

Risk Flags

  • security implications
  • potential breaking change
Loading labels...

Details

Points20 pts
Difficultymedium
Scopesomewhat clear
Skill Matchmaybe
Test Focusedno