Instead of just replacing the contents, fast refresh performs a full page reload if it is an .mdx file.
git clone https://github.com/michel-kraemer/test-nextjs-fast-reload-mdx.gitcd test-nextjs-fast-reload-mdxnpm inpm run devHello World!pages/index.mdxpages/test.jsxInstead of reloading the full page, only the contents should be updated.
–
.mdx file imports/exports a Layout or not.I can confirm this.
I just verified with my project. The page doing full reload on content change in.mdx file.
MDX is not the problem, I managed to get fast refresh working
Fast refresh gets disabled when the page file exports non react stuff (constants, objects, ) that gets consumed in other react files, so make sure you don’t export variables from MDX
Also make sure that your main App component is a named function (should not be export default () => { ... })
If you want to try out fast refresh with MDX files try out Dokz
@remorses Thanks. What you're saying makes sense. But in my case, I don't have any App component and my MDX file does not export variables.
I can confirm this is happening with using the latest canary versions on multiple mdx based sites.
MDX fast refresh does not work for 9.5.0 but works for 9.4.0 in some cases, i can’t find the reason though
Correct, I was trying to do some debugging but came up with nothing. I thought at first perhaps it was from using additional rehype / remark plugins, but none of the base mdx examples work with fast refresh. @timneutkens @Timer, curious if this might be a priority anytime soon!?
Fixed in next@^9.5.2-canary.6 or newer.
I can confirm it works with the latest canary. Thanks for the effort!!
Most helpful comment
Fixed in
next@^9.5.2-canary.6or newer.