Streaming Data with Suspense Boundaries
What you'll learn: How to use Suspense boundaries to stream Server Components progressively as their data resolves, delivering content to users faster.
The Core Idea
In traditional rendering, the entire page waits for all data to load before showing anything. With streaming, you can send HTML to the browser as soon as parts are ready. Suspense boundaries define the "chunks" of your UI that can load independently.
Think of it like a restaurant: instead of waiting for the entire meal to be cooked before serving anything, the waiter brings each dish as soon as it's ready. Your appetizer arrives first, then the main course, then dessert.
How It Works
Wrap slow-loading Server Components in <Suspense> boundaries. React immediately sends everything outside those boundaries, then streams in the wrapped content as data resolves:
import { Suspense } from 'react';
export default function Page() {
return (
<>
<Header /> {/* Sends immediately */}
<Suspense fallback={<ProductsSkeleton />}>
<Products /> {/* Streams in when data ready */}
</Suspense>
<Suspense fallback={<ReviewsSkeleton />}>
<Reviews /> {/* Streams independently */}
</Suspense>
<Footer /> {/* Sends immediately */}
</>
);
}
The Products and Reviews components can fetch data with async/await. React sends the page shell with fallbacks immediately, then replaces each fallback with real content as it arrives—no JavaScript execution needed on the client.
The Performance Win
Users see the header and footer instantly, then products appear when ready, then reviews. The browser can start rendering and users can start reading before everything has loaded. Each Suspense boundary operates independently—a slow database query for reviews won't block products from appearing.
Key Takeaway: Suspense boundaries let you stream Server Components progressively, delivering fast initial renders while slower data loads in the background without blocking the entire page.