Suspense Boundaries Enable Streaming
What you'll learn: How Suspense boundaries define the natural chunk points where React can flush partial HTML and continue rendering the rest.
The Core Idea
When you use renderToPipeableStream, React doesn't automatically know where to split your application into streamable chunks. This is where <Suspense> boundaries become critical: they tell React "this part can wait."
Each <Suspense> boundary creates a natural breaking point in the server render. When React encounters a Suspense boundary with a component that's not ready (like an async Server Component still fetching data), it:
- Immediately flushes all the HTML it's rendered so far
- Sends the fallback UI for that boundary
- Continues rendering other parts of the page
- Later streams in the actual content when ready
Think of Suspense boundaries like chapter markers in a book being printed on-demand. The printer doesn't wait for Chapter 5 to be written before sending you Chapters 1-4. Each <Suspense> is a marker saying "you can ship what you have so far."
Without Suspense
Without Suspense boundaries, renderToPipeableStream behaves almost like renderToString—it waits for everything before sending anything. You get streaming infrastructure, but no actual streaming benefits.
With Suspense
<Suspense fallback={<Spinner />}>
<SlowComponent /> {/* This can stream in later */}
</Suspense>
Now React can flush the shell immediately, send the spinner, and stream <SlowComponent> when it's ready. Multiple Suspense boundaries create multiple independent streaming chunks.
Key Takeaway: Suspense boundaries are the mechanism that unlocks streaming SSR—they define where React can "pause" rendering, flush partial HTML, and continue independently with other parts of the tree.