nextjs - 💡(How to fix) Fix Page re-export leaks server code to browser [2 comments, 3 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
vercel/next.js#87494Fetched 2026-04-08 02:06:58
View on GitHub
Comments
2
Participants
3
Timeline
9
Reactions
0
Timeline (top)
subscribed ×3commented ×2issue_type_added ×1labeled ×1

Code Example

Operating System:
  Platform: win32
  Arch: x64
  Version: Windows 11 Home
  Available memory (MB): 16294
  Available CPU cores: 12
Binaries:
  Node: 24.11.1
  npm: 11.6.2
  Yarn: N/A
  pnpm: 9.0.0
Relevant Packages:
  next: 16.1.0 // Latest available version is detected (16.1.0).
  eslint-config-next: N/A
  react: 19.2.3
  react-dom: 19.2.3
  typescript: N/A
Next.js Config:
  output: N/A
RAW_BUFFERClick to expand / collapse

Link to the code that reproduces this issue

https://github.com/timheerwagen/re-export-page-server-code-leak

To Reproduce

  1. Install dependencies and start the development server: next dev
  2. The server code for the /index page works.
  3. Navigate to /plugin-page - Server Code leaks to browser (Module not found: Can't resolve 'fs/promises')
  4. Navigate to /component-page - Server Code leaks to browser (Module not found: Can't resolve 'fs/promises')

Current vs. Expected behavior

Only the getServerSideProps function in the pages directory works with server code.

Re-exporting a page, whether within the same application package or an external/workspace package (e.g. plugin), leaks server code to the browser.

The docs state a fix, which has already been used to reproduce the issue: https://nextjs.org/docs/messages/export-all-in-page#possible-ways-to-fix-it (export { default, getServerSideProps } from "@repo/page-plugin/pages/index"; )

Provide environment information

Operating System:
  Platform: win32
  Arch: x64
  Version: Windows 11 Home
  Available memory (MB): 16294
  Available CPU cores: 12
Binaries:
  Node: 24.11.1
  npm: 11.6.2
  Yarn: N/A
  pnpm: 9.0.0
Relevant Packages:
  next: 16.1.0 // Latest available version is detected (16.1.0).
  eslint-config-next: N/A
  react: 19.2.3
  react-dom: 19.2.3
  typescript: N/A
Next.js Config:
  output: N/A

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

Pages Router

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

next dev (local)

Additional context

No response

extent analysis

TL;DR

The issue can be mitigated by ensuring that server-side code is not exported to the client-side, potentially by reorganizing the page structure or using a different export method.

Guidance

  • Review the getServerSideProps function in the pages directory to ensure it is correctly handling server-side code and not leaking it to the client-side.
  • Verify that the export { default, getServerSideProps } from "@repo/page-plugin/pages/index"; fix is correctly implemented, as suggested in the Next.js documentation.
  • Check the page structure and exports to ensure that server-side code is not being inadvertently exported to the client-side.
  • Consider reorganizing the page structure to separate server-side and client-side code more effectively.

Example

No specific code example is provided, as the issue is more related to the project structure and export methods.

Notes

The issue seems to be related to the way pages are exported and handled in the Next.js application. The provided fix from the Next.js documentation may not be fully effective, and a more thorough review of the project structure and export methods may be necessary.

Recommendation

Apply workaround: The issue can be mitigated by reorganizing the page structure and export methods to ensure that server-side code is not exported to the client-side. This may involve creating separate files or directories for server-side and client-side code, and using different export methods to handle each type of code.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING

nextjs - 💡(How to fix) Fix Page re-export leaks server code to browser [2 comments, 3 participants]