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.jsAffected 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