Originally published on CodingCush .
A hydration error in Next.js happens when the HTML your server sends does not match what React expects to render in the browser on the first load. React compares the two, finds different text, different tags, or extra elements, and complains. The good news is simple: your app is usually not broken in a deep way. One small piece of code is rendering something different on the server and on the client. Find that piece, make both sides agree, and the error goes away.
Think of two cooks making the same dish: the server cooks first and sends a finished page, then React in the browser cooks the same page again to make it interactive. If the plates do not match, React gets confused. Let us find the real culprit quickly and fix each common cause.
What Does Hydration Actually Mean?
Hydration is the step where a static-looking HTML page becomes alive. The server sends HTML so the page appears fast and search engines can read it.β¦