Skip to main content
Web DevRendering & FrontendDiagramIntermediate

Hydration

KO: 하이드레이션·EN: Hydration·JA: ハイドレーション

The client-side process of attaching JavaScript event listeners and component state to server-rendered HTML so the page becomes interactive

Table of Contents

Structure Diagram

Timeline from Server HTML to Hydration Complete (TTI)
Visual State3 steps
Main Thread (JS)3 steps
STEP 1HTML Parse & Paint (FCP)(25ms)
Quick Answer

What is Hydration?

The client-side process of attaching JavaScript event listeners and component state to server-rendered HTML so the page becomes interactive. It is a core concept in Rendering & Frontend within Web Dev.

Core Principles

Server-rendered HTML (from SSR or SSG) gives users fast visual feedback, but it starts as inert markup. Hydration is the process where client-side JavaScript boots up, walks the existing server-generated DOM without recreating it from scratch, and attaches event listeners and reactive component state.

Between First Contentful Paint and the end of hydration sits the "uncanny valley": the UI looks ready, yet clicks and form inputs appear frozen until the main thread finishes hydrating.

Practical Takeaways

  • Eliminate hydration mismatches: Nondeterministic values during initial render (Date.now(), Math.random(), locale formatting, or window checks) cause server and client trees to diverge, forcing expensive DOM tear-downs and UI flickers. Defer browser-only state to useEffect.
  • Shrink the hydration footprint: Hydrating a massive page monolith blocks the main thread and degrades INP. Use React Server Components, Selective Hydration with <Suspense>, or Islands Architecture so non-interactive markup ships zero JS.
  • Defer below-the-fold widgets: Heavy charts or comment sections can hydrate lazily on viewport intersection or first interaction.

Notable Examples

  • Next.js, Nuxt, and SvelteKit: Deliver server HTML for instant paint, then hydrate into a full client-side routed experience.
  • React 18 Selective Hydration: Prioritizes hydrating the exact <Suspense> boundary the user clicks first, even while other chunks are still streaming.
  • Astro Islands: Keeps static prose at 0 KB of JavaScript and hydrates only interactive islands like carousels or search modals.