Skip to main content

Suspense boundaries and reveal behavior

<Suspense> lets React temporarily show a fallback while part of a render is not ready.

The important mental model is not β€œSuspense is a spinner component.” It is:

A Suspense boundary is a reveal boundary. It coordinates when a subtree may become visible.

import { Suspense } from 'react';

export default function Page() {
return (
<Suspense fallback={<PageSkeleton />}>
<PageContent />
</Suspense>
);
}
Suspense coordinates readiness and revealThe fallback is temporary UI; the boundary is the architectural unit.
Render subtree
Suspend
React finds the closest Suspense boundary.
Fallback
Retry render β†’ reveal content

What can suspend?​

Stable Suspense can participate in work such as:

  • a component loaded with lazy;
  • a Promise read with use;
  • Suspense-enabled framework data sources;
  • stylesheet loading React coordinates;
  • streaming server-rendered content that has not reached the client yet.

Suspense does not automatically detect ordinary fetching started in an Effect or event handler.

useEffect(() => {
fetch('/api/products').then(/* ... */);
}, []);

That is ordinary explicit loading-state code, not Suspense-driven rendering.

The closest boundary handles suspension​

<Suspense fallback={<PageSkeleton />}>
<Header />

<Suspense fallback={<ResultsSkeleton />}>
<SearchResults />
</Suspense>
</Suspense>
Suspension walks upward to the closest boundary
SearchResults suspends
Results Suspense
Shows ResultsSkeleton.
Header + page shell remain visible

If the inner fallback itself suspends, React continues upward to the next Suspense boundary.

Reveal order is UX architecture​

A single large boundary coordinates one reveal. Nested boundaries allow staged reveal.

One boundary vs staged reveal
COORDINATEDSingle boundary

Wait for the whole region, then reveal it together.

PROGRESSIVENested boundaries

Shell β†’ biography β†’ albums β†’ recommendations can reveal in meaningful stages.

Do not wrap every component in Suspense. A boundary should correspond to a loading state the user understands.

First-mount suspension and state​

If a tree suspends before its first successful mount, React retries later; state from the incomplete render attempt is not preserved as mounted state.

A first render can be attempted more than once
First render attempt
No mounted state yet
React retries
Mounted UI + state

This is one reason rendering must remain pure.

Already visible content may suspend again​

If an already revealed region suspends during an urgent update, React may need to replace it with the boundary fallback.

Why transitions and deferred values matter
Urgent suspending update

Visible results β†’ fallback/skeleton β†’ fresh results.

Non-urgent coordinated update

Visible results stay useful β†’ pending/stale feedback β†’ fresh results.

useTransition and useDeferredValue help express when old content is still useful while the next render prepares.

Layout Effects and hidden Suspense content​

If React hides already visible content because it suspended again, layout Effects in that hidden subtree are cleaned up. When the content becomes visible again, layout Effects run again.

useLayoutEffect(() => {
const rect = ref.current.getBoundingClientRect();
// measure currently visible committed layout
}, []);
1Visible commit
2Suspend again
3Layout cleanup
4Reveal again
5Layout setup again

Suspense and Effects solve different problems​

Reveal coordination is not synchronization
RENDER / REVEALSuspense

When is this subtree ready to be shown?

AFTER COMMITEffect

Which external system must be synchronized with committed UI/state?

Suspense and Error Boundaries​

Suspense handles not ready yet. Error Boundaries handle failed rendering/resource work.

A production async region often needs both
Error Boundary
Owns failure recovery.
Suspense Boundary
Owns pending/reveal UX.
Async / lazy region

A rejected lazy import or failed resource should surface to an appropriate error boundary rather than being treated as loading forever.

Suspense does not define caching​

Suspense coordinates rendering when work is not ready. It does not decide cache lifetime, request deduplication, staleness, retries, or mutation invalidation. Those belong to the framework or data layer.

Suspense and server rendering​

Suspense is also part of streaming SSR and hydration architecture.

Suspense spans client and server reveal architecture
Server renders what is ready
Browser receives shell + later content
Interactive UI reveals progressively

The SSR section covers the server APIs in detail.

Boundary placement decision​

What should decide the boundary?
Meaningful region can wait independentlyOwn boundary is a strong candidate
Children should reveal togetherUse one coordinated boundary
Old content is still usefulConsider Transition or deferred stale UI
Region can fail independentlyPair with an Error Boundary

Common mistakes​

Giant root spinner​

<Suspense fallback={<FullScreenSpinner />}>
<EntireApplication />
</Suspense>

A root boundary can be a last resort, but relying only on it makes unrelated regions disappear together.

Expecting Effect fetching to suspend​

function Products() {
const [products, setProducts] = useState(null);

useEffect(() => {
fetchProducts().then(setProducts);
}, []);

if (!products) return <Spinner />;
return <ProductList products={products} />;
}

This is explicit loading-state code. That is validβ€”just know which model you are using.

Destructive fallback replacement​

If a small nested region suspends, avoid replacing a useful whole page with a spinner. Prefer stable shells, localized skeletons, or stale-but-useful content when correct.

Debugging Suspense​

When a fallback appears unexpectedly, inspect:

  1. Which child suspended?
  2. Which boundary is closest?
  3. Was the update urgent or a Transition?
  4. Is the Promise/resource identity stable?
  5. Did a key reset the subtree?
  6. Was a lazy component declared inside another component?
  7. Can the fallback itself suspend?

Production design principle​

Good Suspense architecture tends to produce stable shells, localized skeletons, progressive reveal, visible navigation feedback, stale-but-useful content when appropriate, and separate error recovery.

Exercise​

Build a dashboard with profile, notifications, sales chart, and recent activity. Start with one Suspense boundary, then redesign it with nested boundaries and explain each boundary from the user's perspective.

Interview questions​

Beginner: What does <Suspense> render while its children are not ready?

Intermediate: What kinds of work activate Suspense, and why does fetching inside useEffect not automatically do so?

Senior: How would you place Suspense boundaries for a route with navigation, cached content, streaming server data, and independently slow panels?

Summary​

Suspense mental model
Boundary = reveal contract
Nested boundaries = staged reveal
Error handling and caching remain separate responsibilities

References​

Next​

Next, learn how lazy combines code splitting with Suspense.