-
Notifications
You must be signed in to change notification settings - Fork 29.9k
Closed
Labels
Markdown (MDX)Related to Markdown with Next.js.Related to Markdown with Next.js.bugIssue was opened via the bug report template.Issue was opened via the bug report template.linear: nextConfirmed issue that is tracked by the Next.js team.Confirmed issue that is tracked by the Next.js team.locked
Description
Link to the code that reproduces this issue
https://github.com/pomber/nextjs-mdx-use-client-bug
To Reproduce
- Start the app with
next dev(it only happens in development mode)
Current vs. Expected behavior
Fails with this error:
Unhandled Runtime Error
Error: Cannot access Test.propTypes on the server. You cannot dot into a client module from a server component. You can only pass the imported name through.
Call Stack
Object.get
/workspace/nextjs-mdx-use-client-bug/node_modules/next/dist/compiled/next-server/app-page.runtime.dev.js (22:23981)
React
_createMdxContent
webpack-internal:///(rsc)/./app/hello.mdx (25:74)
MDXContent
webpack-internal:///(rsc)/./app/hello.mdx (45:16)
ej
/workspace/nextjs-mdx-use-client-bug/node_modules/next/dist/compiled/next-server/app-page.runtime.dev.js (22:35053)
Verify canary release
- I verified that the issue exists in the latest Next.js canary release
Provide environment information
$ npx --no-install next info
Operating System:
Platform: linux
Arch: x64
Version: #202309200834 SMP PREEMPT_DYNAMIC Wed Sep 20 09:14:42 UTC 2023
Binaries:
Node: 18.18.0
npm: 9.8.1
Yarn: 1.22.19
pnpm: 8.7.6
Relevant Packages:
next: 13.5.4-canary.4
eslint-config-next: N/A
react: 18.2.0
react-dom: 18.2.0
typescript: 5.1.3
Next.js Config:
output: N/AWhich area(s) are affected? (Select all that apply)
App Router, MDX (@next/mdx)
Additional context
I'm having problems using any client component directly from mdx files:
import { Test } from "./test";
# Hello
<Test />If ./test.js has "use client" this fails in dev mode.
A workaround is to re-export the Test component from a file without "use client".
The same example works with [email protected] and fails with [email protected].
Similar to #52415 but now in v13.5 it happens for every client component.
smakosh, ryota-murakami, dkzlv, bradlc, reinink and 19 more
Metadata
Metadata
Assignees
Labels
Markdown (MDX)Related to Markdown with Next.js.Related to Markdown with Next.js.bugIssue was opened via the bug report template.Issue was opened via the bug report template.linear: nextConfirmed issue that is tracked by the Next.js team.Confirmed issue that is tracked by the Next.js team.locked