Skip to content
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

Open
jeevankc17 opened this issue Jan 22, 2025 · 4 comments
Labels
bug Something isn't working

Comments

@jeevankc17
Copy link

jeevankc17 commented Jan 22, 2025

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.

@jeevankc17 jeevankc17 added the bug Something isn't working label Jan 22, 2025
@dimaMachina
Copy link
Collaborator

Please share a reproduction

@jeevankc17
Copy link
Author

@dimaMachina I separated an single mdx file to multiple to solve the issue actually I have 4000+ lines of code with lot of mathjax.

@dimaMachina
Copy link
Collaborator

Great, so your problem is solved and issue can be closed?

@jeevankc17
Copy link
Author

@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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants