0
0
NextJSframework~10 mins

Streaming with Suspense in NextJS - Step-by-Step Execution

Choose your learning style9 modes available
Concept Flow - Streaming with Suspense
Start Server Component Render
Begin Streaming HTML to Client
Encounter <Suspense> Boundary
Content Ready
Stream Content
Continue Streaming Remaining Content
Complete Streaming
Client Hydrates with Streamed HTML
The server starts rendering and streams HTML to the client. When it hits a Suspense boundary, it streams fallback content immediately while waiting for the main content. Once ready, it streams the main content, then continues streaming the rest.
Execution Sample
NextJS
import { Suspense } from 'react';

export default function Page() {
  return (
    <Suspense fallback={<p>Loading...</p>}>
      <AsyncComponent />
    </Suspense>
  );
}
This code streams fallback content while waiting for AsyncComponent to load, then streams AsyncComponent content when ready.
Execution Table
StepActionContent StreamedSuspense StateClient View
1Start rendering Page componentStart HTML shellNo Suspense triggeredBlank page or initial shell
2Encounter <Suspense> boundaryStream fallback <p>Loading...</p>Suspense fallback shownLoading... message visible
3AsyncComponent starts loadingContinue streaming fallbackStill loadingLoading... message visible
4AsyncComponent finishes loadingStream AsyncComponent contentSuspense resolvedAsyncComponent content replaces fallback
5Stream remaining page contentStream rest of HTMLNo SuspenseFull page content visible
6Client hydrates streamed HTMLNo new streamHydration completePage fully interactive
💡 Streaming ends after all content including Suspense boundaries is sent and client hydration completes.
Variable Tracker
VariableStartAfter Step 2After Step 4Final
Suspense StateNo SuspenseFallback shownResolvedResolved
Content StreamedHTML shellFallback contentAsyncComponent contentFull page content
Client ViewBlankLoading messageAsyncComponent visibleFully interactive page
Key Moments - 2 Insights
Why does the client see the fallback content before the AsyncComponent?
Because at Step 2 in the execution_table, the Suspense boundary streams fallback content immediately while waiting for AsyncComponent to load, so the client sees the fallback first.
What happens when AsyncComponent finishes loading during streaming?
At Step 4, the server streams the AsyncComponent content, replacing the fallback in the client view as shown in the execution_table.
Visual Quiz - 3 Questions
Test your understanding
Look at the execution_table, what is the Suspense State at Step 3?
ANo Suspense triggered
BFallback shown
CSuspense resolved
DHydration complete
💡 Hint
Check the Suspense State column at Step 3 in the execution_table.
At which step does the client view change from fallback to AsyncComponent content?
AStep 4
BStep 2
CStep 3
DStep 6
💡 Hint
Look at the Client View column in the execution_table to see when AsyncComponent content appears.
If AsyncComponent took longer to load, which step would be delayed?
AStep 2
BStep 3
CStep 4
DStep 5
💡 Hint
Step 4 streams AsyncComponent content; longer load delays this step.
Concept Snapshot
Streaming with Suspense in Next.js:
- Server streams HTML progressively.
- <Suspense> streams fallback immediately.
- When async content is ready, streams main content.
- Client sees fallback, then real content replaces it.
- Improves perceived load speed and UX.
Full Transcript
Streaming with Suspense in Next.js means the server sends parts of the page as they are ready. When the server hits a Suspense boundary, it sends fallback content first so the user sees something quickly. Meanwhile, the async content loads. Once ready, the server streams the real content to replace the fallback. This process continues until the full page is sent. Finally, the client hydrates the streamed HTML to make the page interactive. This approach helps pages feel faster and smoother for users.