Course contentsShow
← Web Development
Lesson 1742 of 2,98232. Server-Side Rendering ConceptsFree lesson

What is Hydration?

Understanding how static HTML becomes interactive by attaching JavaScript event listeners and state.

What is Hydration?

You'll learn how server-rendered HTML becomes fully interactive in the browser by "waking up" the JavaScript that powers it.

The Core Concept

When a server sends you fully-rendered HTML (like in SSR or SSG), your browser displays it immediately—users can see the content right away. But that HTML is initially static, like a printed page. The interactive parts (buttons that respond to clicks, forms that validate, animations) don't work yet because the JavaScript isn't connected.

Hydration is the process where JavaScript "attaches" to that static HTML, binding event listeners, initializing component state, and making the page interactive. The framework essentially recreates the component tree in memory and connects it to the existing DOM elements.

Why It's Called Hydration

Think of the server-rendered HTML as a dehydrated meal—it has all the structure and ingredients, but needs water (JavaScript) added to become fully functional. The page goes from being a static document to a living, reactive application.

The Hydration Process

  1. Browser receives and displays static HTML (visible but not interactive)
  2. JavaScript bundle downloads and executes
  3. Framework reads the existing HTML structure
  4. Framework attaches event handlers to matching DOM elements
  5. Component state initializes and synchronizes
  6. Page becomes fully interactive

The critical window between steps 1 and 6 is Hydration Time—users can see content but can't interact with it yet. Clicking buttons during this phase does nothing, which can be frustrating if hydration takes too long.

The Challenge

Hydration must be fast. Slow hydration creates a "uncanny valley" where the page looks ready but isn't. This is why frameworks optimize how they hydrate, sometimes doing it progressively (piece by piece) rather than all at once.

Key Takeaway: Hydration transforms static server-rendered HTML into an interactive application by attaching JavaScript event listeners and initializing state—it's the bridge between fast initial display and full interactivity.