React Hydration

Dan Abramov writes it as: “It’s like watering the “dry” HTML with the “water” of interactivity and event handlers.”

One of the Reddit User define it like, "The server sends the client HTML along with a link to the JS to download. The JS gets downloaded and then “hydrates” the page taking it from a plain page to one with interactivity meaning adding handlers to buttons, events to elements on the page like onClick and so forth."

In one line

In React, hydration refers to the process where client-side JavaScript takes over the static HTML that was rendered on the server.

Take example of NEXT.js and Vite

Hydration is absolutely necessary cause:

  1. Hydration is when React:
  2. Attaches event listeners
  3. Connects the static HTML to the virtual DOM
  4. Reactivates the page so it's interactive