Suspense Boundaries and Streaming Priority
Place Suspense boundaries to control which HTML chunks stream first and when fallbacks become content.
Suspense Boundaries and Streaming Priority is a free React Academy lesson on CoddyKit — lesson 2 of 4. You can read the complete lesson below for free — then practise it hands-on in the browser with a built-in code editor and a 24/7 AI tutor. It is part of the React Academy learning path, one of 4 lessons in the course, and your progress syncs across the web and the CoddyKit app.
Suspense as a Streaming Divider
Suspense boundaries are the fundamental unit of streaming granularity. Each Suspense boundary in your component tree creates an independently streamable section — React can resolve and stream each boundary at its own pace, independent of all others.
The Shell: Fast, Synchronous Content
The shell consists of everything outside of Suspense boundaries — the layout, navigation, footer, and any synchronously available content. The shell streams first and streams fast, giving users the page structure immediately while data-dependent sections load in the background.
Fallbacks in the Initial HTML
When React streams the shell, any Suspense boundary whose data is not yet available renders as its fallback UI — typically a loading skeleton or spinner. This fallback is included in the initial HTML response, so the user sees a loading indicator immediately rather than a blank space.
Resolving and Replacing Fallbacks
When a Suspense boundary's data resolves, React streams the resolved HTML along with a small inline script. That script moves the newly streamed content from a hidden template element into the correct position in the DOM, replacing the fallback without a full page reload.
The Inline Script Pattern
React uses the HTML template element pattern: resolved Suspense content is streamed into a hidden template, then a script calls a React internal function to swap the template content into the correct DOM position. This enables zero-JS-framework DOM manipulation for the replacement.
Nested Suspense: Independent Timelines
Nested Suspense boundaries have independent resolution timelines. An inner Suspense boundary can resolve before its outer boundary — React streams the inner content as soon as it's ready, regardless of whether the outer boundary has resolved. This maximizes parallelism in data loading.
Placement Strategy: What Goes Where
Effective Suspense placement puts slow, data-dependent components inside Suspense boundaries and fast, static, or synchronously available content outside. Navigation bars, hero sections with static text, and footers belong outside. Product listings, user dashboards, and comment feeds belong inside.
Streaming Order: Not Necessarily Document Order
React streams Suspense boundaries as they resolve — not necessarily in the order they appear in the document. A below-fold section might resolve before an above-fold section if it requires less data. React handles the DOM insertion correctly regardless of streaming order.
Priority Hints and User Interaction
React 18's selective hydration responds to user interaction: if the user clicks or hovers over a Suspense boundary that hasn't hydrated yet, React prioritizes hydrating that boundary first. This ensures user interactions feel responsive even when other parts of the page are still hydrating.
Avoiding Over-Granular Boundaries
More Suspense boundaries mean more streaming flexibility, but too many add overhead from inline replacement scripts. A practical guideline: wrap entire "sections" (above-fold content, sidebar, below-fold feed) rather than individual components. One to three Suspense boundaries per page is a common sweet spot.
Measuring Streaming Impact with Chrome DevTools
In Chrome DevTools Network tab, use "Preserve log" and observe the response streaming: the HTML document grows in chunks. The Performance tab shows FCP and LCP markers — compare between streaming and non-streaming builds to quantify the improvement. Throttle to Fast 3G to exaggerate the effect.
Suspense Fallback in Streaming HTML
What happens to a Suspense boundary's fallback in the initial streaming HTML response?
Lesson Recap
Suspense boundaries divide your React tree into independently streamable sections. The shell (outside Suspense) streams first; fallbacks appear immediately for pending boundaries; resolved content replaces fallbacks via inline scripts. Nested boundaries have independent timelines. Place boundaries at the section level for optimal streaming granularity, and let React's priority system handle interaction-driven hydration order.
Frequently asked questions
Is the “Suspense Boundaries and Streaming Priority” lesson free?
Yes — the full text of “Suspense Boundaries and Streaming Priority” is free to read here on the web, and the React Academy course includes 4 lessons in total. To practise it interactively (a built-in code editor and a 24/7 AI tutor) and unlock the rest of the React Academy course, upgrade to CoddyKit PRO.
What will I learn in “Suspense Boundaries and Streaming Priority”?
Place Suspense boundaries to control which HTML chunks stream first and when fallbacks become content. You practise React Academy with hands-on code you run directly in the browser, and a 24/7 AI tutor answers your questions as you work through the lesson.
Do I need any experience to start React Academy?
No prior experience is required. React Academy on CoddyKit is structured for beginners through advanced learners; this is — lesson 2 of 4, so you can start here or from the beginning and move at your own pace.
How long does the “Suspense Boundaries and Streaming Priority” lesson take?
Most CoddyKit lessons take about 5–10 minutes. Each one is bite-sized and interactive, so you make steady progress and pick up exactly where you left off across the web and the app.
Can I write and run code in this React Academy lesson?
Yes. Every React Academy lesson includes a built-in code editor, so you write and run real code right in your browser and get instant AI feedback — no local setup required.
All lessons in this course
- React 18 Streaming: How renderToPipeableStream Works
- Suspense Boundaries and Streaming Priority
- Progressive Hydration with Selective Hydration
- Measuring Streaming Impact: FCP, TTI, and LCP