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

The Double Data Problem

Understanding why hydration requires serializing state from server to client and its implications.

The Double Data Problem

You'll learn why SSR + hydration can result in sending the same data twice and what that means for performance.

When you use Server-Side Rendering with hydration, you face an interesting challenge: the server renders your components into HTML using data it fetched (like user info or product details), but then the client needs that same data to hydrate those components and make them interactive.

The Core Issue

The server sends fully-rendered HTML containing the visual representation of your data—for example, a product list with prices and images. But when your JavaScript bundle loads and React (or another framework) tries to hydrate that HTML, it needs the original data objects to attach event handlers and manage state.

Without that data, hydration can't work properly. The client would need to re-fetch everything, causing a flash of empty content and wasted network requests.

The Solution Creates Duplication

The typical solution is state serialization: the server embeds the data as JSON directly in the HTML (often in a <script> tag). Now your HTML contains both:

  1. The rendered markup (the visual data)
  2. A JSON blob (the raw data)

This is the "double data problem"—the same information appears twice in different formats, increasing your page size.

Implications

  • Larger initial payload: More bytes to download before the page is visible
  • Necessary trade-off: Without it, you'd lose hydration benefits or cause poor UX
  • Optimization opportunity: Minimize serialized state by only including what's needed for hydration

Key Takeaway:
SSR with hydration requires sending data twice—once as rendered HTML and once as serialized state for client-side hydration—creating a performance trade-off between page size and interactivity.