-
Notifications
You must be signed in to change notification settings - Fork 27k
This issue was moved to a discussion.
You can continue the conversation there. Go to discussion →
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
MDX support width appDir enabled #47523
Comments
I've ran into this as well. I tried splitting up the mdx code as components, adding a // stuff.mdx
"use client"
# hello // page.tsx
import Hello from "./stuff.mdx"
export default function DoesntWork() {
return <Hello />
} |
@Doodidan I believe you need to import your mdx file in your page.tsx. Your example code shows just a page.md file with markdown.
This should work in |
I am having the same issue and have a reproduction with an mdx file - https://github.com/MatthewCaseres/mdx-repro. I am going to close my duplicate issue and just follow this issue. @traversng do you have an example I can clone from where it is working properly with latest version? |
Hi @MatthewCaseres for your case, if you move |
@tannerabread Thank you! The repo is updated to help as a working example for others who are having issues. |
Yes, I found working eample with this. But plain .mdx files without page.tsx work fine with old architecture. So, I find it as a bug. |
Thanks for the solution @Doodidan. It only works when I set the |
@kossidts In my case, it was fixed when adding the mdx-components.tsx file as mentioned in the docs, and adding mdxRs: true in the config. It does work (for me) without |
Hey folks! Chiming in that I've encountered this error as a somebody new to NextJS and getting up to speed with MDX. The instructions as is in the live docs invariably result in the same message reported above:
So my question: What's the intended path for usage of MDX going forward? What should I expect? I'm fine using the implementation proposed (import MDX content into a TSX component and render from there with the appropriate client/server pragma)--but it'd be nice to know if the documentation is out of date or this is an ephemeral implementation issue within NextJS 13.x. Cheers! |
@damien Are you using the mdx-components.tsx file and setting mdxRs: true in the config? |
I did this but am still experiencing the error. I don't know how to debug what is causing this, in part because I don't understand how |
@mizlan Just to be sure, I followed these instructions: https://nextjs.org/docs/app/building-your-application/configuring/mdx (there is a possible gotcha of following the instructions for |
Hmm, yeah I followed that. Also to note, I am trying to use it via a dynamic import, like as here (except his works and mine doesn't, for some reason...) |
@mizlan I am not sure if this is the solution but I think you need to configure pageExtensions to include md and mdx
|
Ah I resolved it, I did something dumb. (I had the "if you're gonna use MDXProvider" part uncommented without actually using that) Thanks for your time and help! |
This is the solution! |
Yes, in my experience import React from "react"
import type { MDXComponents } from "mdx/types"
export function useMDXComponents(components: MDXComponents): MDXComponents {
return {
...components
}
} |
placing mdx-components.tsx in the root of project fix this issue |
Not working with contentlayer + mdx + app |
This seems to work: 'use client';
import Content from "./content.mdx";
export default function Page() {
return <Content />;
} |
How I moved from ContentLayer to Next MDX. ContentLayer seems to no longer be maintained and has a lot of bugs: |
Thanks! It helped. |
Anyone that has a good explanation to why I have to add "use client" to my page for it to render? This is what my page.tsx looks like:
As I see it that should completely valid without "use client". |
Okay,after 30mins checking,I finally found the solution for me:
|
Still doesn't work for me :( |
this works but need to add "use client" directive on |
This issue was moved to a discussion.
You can continue the conversation there. Go to discussion →
Verify canary release
Provide environment information
Which area(s) of Next.js are affected? (leave empty if unsure)
App directory (appDir: true), MDX (@next/mdx)
Link to the code that reproduces this issue
https://github.com/GoshaEgorian/next-mdx-bug-reproduction
To Reproduce
Describe the Bug
MDX cannot be rendered with new app dir 'cause of context
Expected Behavior
MDX renders normally
Which browser are you using? (if relevant)
No response
How are you deploying your application? (if relevant)
No response
The text was updated successfully, but these errors were encountered: