-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Hydration Error When Dynamically Importing MDX File also after SSR Disabled when use more mathjax file #3997
Comments
Please share a reproduction |
@dimaMachina I separated an single mdx file to multiple to solve the issue actually I have 4000+ lines of code with lot of mathjax. |
Great, so your problem is solved and issue can be closed? |
@dimaMachina hey I have a mathematical expression that is only supported by the mathjax library, I used mathjax on page router and working absolutely fine but now facing issue on app router, working fine somewhere but not everywhere. For now I am planning to stay with the page router until that issue not being solved. |
please share reproduction repo |
hey finally got solved, mathjax not working on the app router properly as it is javascript client library where as katex with cdn used on the head tag on layout.tsx work absolutely fine |
When using dynamic imports with SSR disabled in a Next.js project to load an .mdx file containing huge math expression, a hydration error occurs. The server-rendered HTML doesn't match the client-rendered HTML, causing the component to re-render on the client. SSR Disabled also can't solving the issue
To Reproduce
Set up a Next.js project with the nextra package for MDX support.
Create an .mdx file and place it inside a content directory.
Write file with lot of Math Expressions
Dynamically import the .mdx file in a page using dynamic(() => import('../content/file.mdx'), { ssr: false }).
Run the Next.js app in development mode.
See the hydration error in the browser's console.
Expected behavior
The .mdx file should be rendered correctly without causing any hydration issues. The dynamic import should disable SSR and render the content without any mismatches between the server and client-rendered HTML.
Desktop (please complete the following information):
OS: Windows 11
Browser: Google Chrome
Version: 108.0.5359.125
The issue occurs even when using nextra for MDX support.
Tried using dynamic() import with SSR disabled, but the error persists.
The .mdx file is located in the /content directory and is correctly formatted.
The text was updated successfully, but these errors were encountered: