AI & Agent Dev Bug Sandbox logo
AI & Agent Dev Bug Sandbox
Back to Radar

MDX Component Function Passed To Client Component Fails With Cache Components And Partial Prerendering

When using Next.js 16.3.1-canary.1 with Cache Components and Partial Prerendering enabled, dynamic imported MDX components are treated as Server Component functions and passed directly to a Client Component, causing the error 'Functions cannot be passed directly to Client Components'. The fix is to render the MDX component to a React element before passing it to the client, typically by using it as children or as a rendered prop.

highConfidence 85%Next.jsnext buildApp RouterReact Server ComponentsAffected V16.3.1-Canary.1

Origin Analysis

Dynamic import of an MDX file returns a Server Component function. Passing this function as a prop to a Client Component violates React Server Component serialization rules, which prohibit passing function references to client components. Cache Components and Partial Prerendering make this serialization step more explicit, triggering the error.
1. Enable cacheComponents and partial prefetching in a Next.js 16.3.1-canary.1 project. 2. Use dynamic import to load an MDX file in a Server Component. 3. Pass the imported component function (e.g., `Content`) to a Client Component as a prop. 4. Run `npm run dev` and navigate to the page. Observe the error in the browser console.

Fixing Code Block

Edge Case Audit

Ensure the Client Component accepts `children` or expects a rendered element prop. Avoid using `dynamic(..., { ssr: false })` for MDX in this scenario because it forces MDX into a client component, potentially bloating client bundle and breaking server-only MDX features. If you need to pass a prop, use `content={<MDXContent />}` instead of `content={MDXContent}`. Rollback suggestion: if this change does not resolve the issue, revert to static imports or disable cacheComponents/PPR until the upstream bug is fixed.

Ecosystem Topology

Agent Frameworks

LangChain, LlamaIndex, and Pydantic

  1. highProperty graph relation keys collide when entity IDs or labels contain underscores
  2. highCodeActAgent drops assistant tool-call metadata during handoff, leaving an orphan tool response
  3. high[Bug]: HierarchicalNodeParser async methods return the documents unsplit
  4. highLLM.predict_and_call fails with ValidationError for non-function-calling models when react_chat_formatter is omitted
  5. highAnthropic streaming server-tool input_json_delta overwrites completed client tool_use arguments due to stale cur_tool_call state