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

[Next.js 13] Hydration failed because the initial UI does not match what was rendered on the server #34893

Closed
2 tasks done
ocavue opened this issue Oct 26, 2022 · 21 comments · Fixed by #34970
Closed
2 tasks done
Assignees
Labels
duplicate This issue or pull request already exists package: system Specific to @mui/system

Comments

@ocavue
Copy link
Contributor

ocavue commented Oct 26, 2022

Duplicates

  • I have searched the existing issues

Latest version

  • I have tested the latest version

Steps to reproduce 🕹

Open https://stackblitz.com/github/mui/material-ui/tree/master/examples/nextjs, which will install the latest MUI and Next.js (v13)

Current behavior 😯

Unhandled Runtime Error
Error: Hydration failed because the initial UI does not match what was rendered on the server.

image

Expected behavior 🤔

No error during development.

Context 🔦

Next.js 13 is just released. Check their blog: https://nextjs.org/blog/next-13

Your environment 🌎

N/A

@ocavue ocavue added the status: waiting for maintainer These issues haven't been looked at yet by a maintainer label Oct 26, 2022
@zannager zannager added package: system Specific to @mui/system examples Relating to /examples labels Oct 26, 2022
@mnajdova
Copy link
Member

Thanks for pointing this out, I will check to see what updates we'll need to do.

@mnajdova mnajdova added bug 🐛 Something doesn't work and removed status: waiting for maintainer These issues haven't been looked at yet by a maintainer labels Oct 26, 2022
@oliviertassinari
Copy link
Member

Next.js document an example with styled-components for client-side components, since we have a working adapter for styled-components, it could be a temporary workaround https://beta.nextjs.org/docs/styling/css-in-js#styled-components but they mention nothing for server side.

@FullstackJack
Copy link

I think I solved this in my project by removing the MUI Link component from inside the Next.js Link component. If I recall, I used component={NextLink} and removed passHref.

@juliorochafilho
Copy link

This happens for me when I try to use version 13.0.3 of Next JS , using 13.0.0 it works fine.

@pcreehan
Copy link

pcreehan commented Dec 8, 2022

This happens for me when I try to use version 13.0.3 of Next JS , using 13.0.0 it works fine.

Same. I'm seeing this as well @mnajdova this may need reopened.

@oliviertassinari
Copy link
Member

Do you have a reproduction?

@kristianstroka
Copy link

I have same issue, nothing special, I used nextjs for a years, and now updated from 12 to 13, and see this error on first render

@mnajdova
Copy link
Member

There were updates in our example, it was around the Link component (and additional font updates too). The Link update is necessary for fixing the hydration errors, so I would recommend looking at that. This is the PR that fixed this issue: #34970

@AChangXD
Copy link

AChangXD commented May 6, 2023

Seeing this with the following error:

Warning: Prop className did not match. Server: "MuiStepIcon-text css-117w1su-MuiStepIcon-text" Client: "MuiStepIcon-text css-opt7yd-MuiStepIcon-text"

I am using a custom theme

@mnajdova
Copy link
Member

@AChangXD please open an issue with a reproduction.

@aiet7
Copy link

aiet7 commented May 12, 2023

Why release a half ass product? Remove next 13 from production until it is FULLY ready. Way too many errors.

@diegoleft
Copy link

Same issues here, unfortunately the log does not provide specific details about the location of the error.
This error is not closed

@Tmcerlean
Copy link

Having the same issue here.

@hifilorau
Copy link

getting this error but only in a input type="password" if i take it off then it works fine. But it's a password field so... not ideal

@oliviertassinari
Copy link
Member

I'm cleaning the issues.

@oliviertassinari
Copy link
Member

oliviertassinari commented Jul 22, 2023

Duplicate of #34896

@oliviertassinari oliviertassinari marked this as a duplicate of #34896 Jul 22, 2023
@oliviertassinari oliviertassinari removed the bug 🐛 Something doesn't work label Jul 22, 2023
@oliviertassinari oliviertassinari added duplicate This issue or pull request already exists and removed examples Relating to /examples labels Jul 22, 2023
@word-x
Copy link

word-x commented Oct 5, 2023

I upgraded to NextJS 13.5.4 and React 18.2.0, it shows the same error as you guys.

But this combination works fine.
"next": "12.3",
"react": "18.2.0",

Actually, I found that new NextJS 13.5 is not compatible with some MUI component. In my case, it is probably Drawler. If I set the vairant as "permanent", it shows a Hydration failed error.

@sass-developer
Copy link

I think I solved this in my project by removing the MUI Link component from inside the Next.js Link component. If I recall, I used component={NextLink} and removed passHref.

it worked for me

@sass-developer
Copy link

Having the same issue here.

@im-Kazmi
Copy link

same problem here

@im-Kazmi
Copy link

I think I solved this in my project by removing the MUI Link component from inside the Next.js Link component. If I recall, I used component={NextLink} and removed passHref.

it worked for me
it worked for me also

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
duplicate This issue or pull request already exists package: system Specific to @mui/system
Projects
None yet
Development

Successfully merging a pull request may close this issue.