Lesson 5 of 7
Streaming & Progressive Rendering
React 18 + Next.js can stream HTML to the browser before all data is ready. This means users see content immediately - fast parts render first, Suspense boundaries show skeletons, and slow parts stream in without blocking the whole page.
Streaming with Suspense
// Next.js App Router streaming - Suspense boundaries become stream flush points
// app/dashboard/page.tsx
import { Suspense } from 'react';
// This page streams - users see the layout immediately
// Each Suspense boundary flushes when its data is ready
export default async function DashboardPage() {
return (
<div>
<header>Dashboard</header> {/* โ immediate: no data needed */}
{/* Fast metrics - streams in ~100ms */}
<Suspense fallback={<MetricsSkeleton />}>
<QuickMetrics />
</Suspense>
{/* Slow analytics - streams in ~1500ms */}
<Suspense fallback={<ChartSkeleton />}>
<AnalyticsChart /> {/* fetches from slow analytics API */}
</Suspense>
{/* Very slow ML recommendations - streams in ~3000ms */}
<Suspense fallback={<RecommendationsSkeleton />}>
<AiRecommendations /> {/* calls ML service */}
</Suspense>
</div>
);
}
// QuickMetrics - server component, awaits fast API
async function QuickMetrics() {
const metrics = await fetchQuickMetrics(); // fast (~50ms)
return <MetricsDisplay data={metrics} />;
}
// AnalyticsChart - server component, awaits slow API
async function AnalyticsChart() {
const data = await fetchAnalytics(); // slow (~1200ms)
return <Chart data={data} />;
}
// Without streaming (traditional SSR):
// User waits for ALL data (3000ms) before seeing ANYTHING
// With streaming:
// User sees layout + skeletons immediately (0ms)
// Metrics appear at ~100ms
// Chart appears at ~1500ms
// Recommendations appear at ~3000msTip
Tip
Practice Streaming Progressive Rendering in small, isolated examples before integrating into larger projects. Breaking concepts into small experiments builds genuine understanding faster than reading alone.
Visual architecture and flow for Streaming & Progressive Rendering
Practice Task
Note
Practice Task - (1) Write a working example of Streaming Progressive Rendering from scratch without looking at notes. (2) Modify it to handle an edge case (empty input, null value, or error state). (3) Share your solution in the Priygop community for feedback.
Quick Quiz
Common Mistake
Warning
A common mistake with Streaming Progressive Rendering is skipping edge case testing - empty inputs, null values, and unexpected data types. Always validate boundary conditions to write robust, production-ready react code.
Finished this lesson?