Replies: 28 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 />
} |
Beta Was this translation helpful? Give feedback.
-
@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 |
Beta Was this translation helpful? Give feedback.
-
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? |
Beta Was this translation helpful? Give feedback.
-
Hi @MatthewCaseres for your case, if you move |
Beta Was this translation helpful? Give feedback.
-
@tannerabread Thank you! The repo is updated to help as a working example for others who are having issues. |
Beta Was this translation helpful? Give feedback.
-
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. |
Beta Was this translation helpful? Give feedback.
-
Thanks for the solution @Doodidan. It only works when I set the |
Beta Was this translation helpful? Give feedback.
-
@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 |
Beta Was this translation helpful? Give feedback.
-
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! |
Beta Was this translation helpful? Give feedback.
-
@damien Are you using the mdx-components.tsx file and setting mdxRs: true in the config? |
Beta Was this translation helpful? Give feedback.
-
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 |
Beta Was this translation helpful? Give feedback.
-
@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 |
Beta Was this translation helpful? Give feedback.
-
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...) |
Beta Was this translation helpful? Give feedback.
-
@mizlan I am not sure if this is the solution but I think you need to configure pageExtensions to include md and mdx
|
Beta Was this translation helpful? Give feedback.
-
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! |
Beta Was this translation helpful? Give feedback.
-
This is the solution! |
Beta Was this translation helpful? Give feedback.
-
Yes, in my experience import React from "react"
import type { MDXComponents } from "mdx/types"
export function useMDXComponents(components: MDXComponents): MDXComponents {
return {
...components
}
} |
Beta Was this translation helpful? Give feedback.
-
placing mdx-components.tsx in the root of project fix this issue |
Beta Was this translation helpful? Give feedback.
-
Ensure |
Beta Was this translation helpful? Give feedback.
-
Not working with contentlayer + mdx + app |
Beta Was this translation helpful? Give feedback.
-
This seems to work: 'use client';
import Content from "./content.mdx";
export default function Page() {
return <Content />;
} |
Beta Was this translation helpful? Give feedback.
-
How I moved from ContentLayer to Next MDX. ContentLayer seems to no longer be maintained and has a lot of bugs: |
Beta Was this translation helpful? Give feedback.
-
Thanks! It helped. |
Beta Was this translation helpful? Give feedback.
-
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". |
Beta Was this translation helpful? Give feedback.
-
Okay,after 30mins checking,I finally found the solution for me:
|
Beta Was this translation helpful? Give feedback.
-
Still doesn't work for me :( |
Beta Was this translation helpful? Give feedback.
-
this works but need to add "use client" directive on |
Beta Was this translation helpful? Give feedback.
-
Hi everyone— We technically do support MDX with App Router. Since there seems to be a variety of setup issues folks are coming across, I have moved this over to discussions. There seems to be some clarification needed in our Documentation around the setup of it that could be beneficial :one-eye-cowboy: |
Beta Was this translation helpful? Give feedback.
-
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
Beta Was this translation helpful? Give feedback.
All reactions