Hydration Time
You'll learn what hydration time is, why it matters for server-rendered apps, and how to optimize this critical window between static HTML and full interactivity.
What Is Hydration Time?
When using Server-Side Rendering (SSR), the server sends fully-rendered HTML to the browser. Users can see content immediately (measured by FCP and LCP), but they can't interact with it yet. The JavaScript framework must "hydrate" this static HTML by attaching event listeners, initializing state, and making components interactive.
Hydration time measures how long this transformation takes—from when the HTML loads to when the app becomes fully interactive (TTI).
Why It Matters
Think of hydration like waking up a robot: the physical body arrives first (HTML), but it needs its brain activated (JavaScript) before it can respond to commands. A long hydration time creates a frustrating "uncanny valley" where buttons look clickable but don't respond, leading to user frustration and poor First Input Delay (FID) scores.
Measuring Hydration Time
// Mark start of hydration
performance.mark('hydration-start');
// Your framework hydrates...
app.hydrate('#root');
// Mark end and measure
performance.mark('hydration-end');
performance.measure('hydration', 'hydration-start', 'hydration-end');
const hydrationTime = performance.getEntriesByName('hydration')[0].duration;
console.log(`Hydration took ${hydrationTime}ms`);
Optimization Strategies
- Reduce JavaScript bundle size: Less code to parse and execute
- Progressive hydration: Hydrate visible components first
- Lazy hydration: Delay non-critical component hydration
- Pre-optimize HTML structure: Match server/client rendering exactly to avoid mismatches
Key Takeaway: Hydration time bridges the gap between visible content and interactive functionality—optimize it to ensure users can engage with your SSR app as quickly as possible.