nextjs - 💡(How to fix) Fix TS Plugin doesn't catch non-serializable props being passed to client components [1 comments, 2 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#86748Fetched 2026-04-08 02:09:28
View on GitHub
Comments
1
Participants
2
Timeline
3
Reactions
1
Timeline (top)
commented ×1issue_type_added ×1labeled ×1

Error Message

Error occurred prerendering page "/". Read more: https://nextjs.org/docs/messages/prerender-error Error: Functions cannot be passed directly to Client Components unless you explicitly expose it by marking it with "use server". Or maybe you meant to call this function rather than return it. {foo: function foo} ^^^^^^^^^^^^ at stringify (<anonymous>) { digest: '3523004343' } Export encountered an error on /page: /, exiting the build. ⨯ Next.js build worker exited with code: 1 and signal: null error: script "build" exited with code 1

Code Example

Error occurred prerendering page "/". Read more: https://nextjs.org/docs/messages/prerender-error
Error: Functions cannot be passed directly to Client Components unless you explicitly expose it by marking it with "use server". Or maybe you meant to call this function rather than return it.
  {foo: function foo}
        ^^^^^^^^^^^^
    at stringify (<anonymous>) {
  digest: '3523004343'
}
Export encountered an error on /page: /, exiting the build.
  Next.js build worker exited with code: 1 and signal: null
error: script "build" exited with code 1

---

Operating System:
  Platform: darwin
  Arch: arm64
  Version: Darwin Kernel Version 24.6.0: Mon Aug 11 21:15:09 PDT 2025; root:xnu-11417.140.69.701.11~1/RELEASE_ARM64_T6041
  Available memory (MB): 49152
  Available CPU cores: 14
Binaries:
  Node: 22.21.1
  npm: 10.9.4
  Yarn: 1.22.22
  pnpm: 10.24.0
Relevant Packages:
  next: 16.0.6 // Latest available version is detected (16.0.6).
  eslint-config-next: N/A
  react: 19.2.0
  react-dom: 19.2.0
  typescript: 5.9.3
Next.js Config:
  output: N/A
RAW_BUFFERClick to expand / collapse

Link to the code that reproduces this issue

https://github.com/chriskrogh/next-serializable-prop-issue/

To Reproduce

  • run bun run build or bun run tsc

Current vs. Expected behavior

  • Current behaviour
    • build and type checker pass without any issues
  • Expected behaviour
    • build and type checker will fail given that we're passing a non-serializable prop from a server component to a client component.

Note:

  • The server component needs to be dynamic such that NextJS doesn't attempt to pre-render it. If the server component is pre-renderable, then NextJS does detect the issue and fails to build:
Error occurred prerendering page "/". Read more: https://nextjs.org/docs/messages/prerender-error
Error: Functions cannot be passed directly to Client Components unless you explicitly expose it by marking it with "use server". Or maybe you meant to call this function rather than return it.
  {foo: function foo}
        ^^^^^^^^^^^^
    at stringify (<anonymous>) {
  digest: '3523004343'
}
Export encountered an error on /page: /, exiting the build.
 ⨯ Next.js build worker exited with code: 1 and signal: null
error: script "build" exited with code 1

However, if the component is dynamic, then the issue is hidden until runtime.

<img width="980" height="296" alt="Image" src="https://github.com/user-attachments/assets/37c1a2a0-14c3-4497-a643-045dd1b41f91" />

we are using the "plugins": [{"name": "next"}], plugin in the tsconfig.json

Provide environment information

Operating System:
  Platform: darwin
  Arch: arm64
  Version: Darwin Kernel Version 24.6.0: Mon Aug 11 21:15:09 PDT 2025; root:xnu-11417.140.69.701.11~1/RELEASE_ARM64_T6041
  Available memory (MB): 49152
  Available CPU cores: 14
Binaries:
  Node: 22.21.1
  npm: 10.9.4
  Yarn: 1.22.22
  pnpm: 10.24.0
Relevant Packages:
  next: 16.0.6 // Latest available version is detected (16.0.6).
  eslint-config-next: N/A
  react: 19.2.0
  react-dom: 19.2.0
  typescript: 5.9.3
Next.js Config:
  output: N/A

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

React

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

next build (local)

Additional context

No response

extent analysis

TL;DR

  • The issue can be mitigated by ensuring that non-serializable props are not passed from server components to client components, potentially by using a different data structure or by explicitly marking functions as serializable.

Guidance

  • Review the code to identify where non-serializable props are being passed from server components to client components.
  • Consider using a library or utility function to serialize or transform non-serializable data before passing it to client components.
  • Verify that the tsconfig.json and Next.js configurations are correctly set up to detect and prevent non-serializable props from being passed.
  • Test the application with different scenarios to ensure that the issue is fully resolved and does not reappear at runtime.

Example

No specific code example can be provided without modifying the original code, but ensuring that functions are not directly passed as props can be achieved by calling the function and passing its result instead.

Notes

The provided environment information and package versions may influence the behavior and available solutions, but without further details, it's challenging to provide a more specific fix.

Recommendation

Apply workaround: The current issue seems to be related to how Next.js handles serializable props in dynamic server components. Until a more permanent solution is available, applying workarounds such as serializing data before passing it to client components or restructuring the code to avoid passing non-serializable props directly can help mitigate the issue.

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 TS Plugin doesn't catch non-serializable props being passed to client components [1 comments, 2 participants]