Selective Hydration with Suspense Boundaries
What you'll learn: How to wrap parts of your component tree in Suspense to enable streaming SSR and prioritize hydration of interactive sections first.
The Problem with Traditional Hydration
By default, hydration is all-or-nothing and synchronous. The entire component tree must hydrate before any part becomes interactive. If you have a heavy component (like a large comments section), it blocks the entire page from being interactive—even simple buttons elsewhere can't respond to clicks until everything is done.
The Suspense Solution
When you wrap parts of your tree in <Suspense> boundaries during SSR, React gains two superpowers:
1. Streaming SSR: The server can send HTML in chunks. Heavy components inside Suspense boundaries don't block the initial HTML. They stream in later when ready.
2. Selective Hydration: The client doesn't wait for everything. Components outside Suspense boundaries hydrate immediately. Components inside Suspense boundaries hydrate when their code arrives—and React prioritizes based on user interaction.
How It Works
<div>
<Header /> {/* Hydrates immediately */}
<Suspense fallback={<Spinner />}>
<Comments /> {/* Hydrates later, when ready */}
</Suspense>
<Footer /> {/* Hydrates immediately */}
</div>
If the user clicks on <Footer> before <Comments> has hydrated, React prioritizes hydrating <Footer> first. The user gets interactivity where they're engaging, not based on arbitrary order.
The Analogy
Think of a restaurant with multiple tables. Traditional hydration is like waiting for every table's food to be ready before serving anyone. Selective hydration serves tables as their orders complete—and if a customer signals their waiter, that order gets priority in the kitchen.
Key Takeaway: Wrap non-critical or heavy components in Suspense boundaries to enable streaming SSR and user-interaction-driven hydration priority, dramatically improving perceived performance and time to interactive.