Suspense loading and navigation architecture
Knowing the <Suspense> API is not enough for production systems. You also need to decide what stays visible, what may show a skeleton, what reveals together, when old content remains useful, when identity must reset, and where failure recovery lives.
Design the user-visible sequence firstβ
<PageShell>
<Suspense fallback={<ProfileSkeleton />}>
<Profile />
</Suspense>
<DashboardGrid>
<Suspense fallback={<ChartSkeleton />}>
<RevenueChart />
</Suspense>
<Suspense fallback={<ActivitySkeleton />}>
<RecentActivity />
</Suspense>
</DashboardGrid>
</PageShell>
Boundary granularity is a UX contractβ
Boundary placement should align with user-visible loading units, not arbitrary component boundaries.
Keep useful UI visible during navigationβ
A route update that suspends can replace already visible content with a fallback. Marking navigation as a Transition lets React prepare the next route without unnecessarily destroying the current one.
import { useTransition } from 'react';
function Router() {
const [page, setPage] = useState('/');
const [isPending, startTransition] = useTransition();
function navigate(nextPage) {
startTransition(() => {
setPage(nextPage);
});
}
return (
<Layout pending={isPending}>
<Route page={page} navigate={navigate} />
</Layout>
);
}
Preserving old content does not mean hiding progress. Show pending feedback in navigation or another stable region.
Transitions do not wait for every nested boundaryβ
A Transition can protect already revealed outer UI from an unwanted fallback, while new nested boundaries still show their own loading states.
Stale content can be better than fallback replacementβ
For search, filtering, charts, and exploration, old results may remain useful while fresh results prepare.
const deferredQuery = useDeferredValue(query);
const isStale = query !== deferredQuery;
return (
<Suspense fallback={<ResultsSkeleton />}>
<div aria-busy={isStale} style={{ opacity: isStale ? 0.6 : 1 }}>
<SearchResults query={deferredQuery} />
</div>
</Suspense>
);
If stale content stays visible, communicate that state with opacity, aria-busy, an βUpdatingβ¦β label, or another appropriate signal.
Reset for genuinely different identityβ
Transitions preserve useful content. Sometimes that is wrong because the entity itself changed.
<ProfilePage key={userId} userId={userId} />
Do not use unstable keys like Date.now() as βforce refreshβ buttons.
Loading and failure architecture belong togetherβ
<RouteErrorBoundary>
<Suspense fallback={<RouteSkeleton />}>
<RouteContent />
</Suspense>
</RouteErrorBoundary>
Loading architecture cannot fix waterfalls by itselfβ
Suspense can reveal progressively, but sequential resource discovery is still sequential.
Start independent work early where the framework/data architecture allows it. Route prefetching, module preloading, server rendering, and parallel data work can all reduce discovery waterfalls.
Navigation priorityβ
Text input control remains urgent.
Bad:
startTransition(() => {
setQuery(event.target.value);
});
Better:
setQuery(event.target.value);
const deferredQuery = useDeferredValue(query);
Route-layer mental modelβ
Not every app needs every layer. The point is to avoid making one root fallback responsible for every loading experience.
Production patternsβ
Searchβ
Settings navigationβ
Debugging checklistβ
If loading/navigation feels wrong, ask:
- Which update caused suspension?
- Was it urgent or a Transition?
- Which Suspense boundary is closest?
- Was that boundary already showing real content?
- Can nested boundaries show local fallbacks?
- Did a key intentionally reset identity?
- Is stale content acceptable and communicated?
- Is pending state visible?
- Is there a request/chunk waterfall?
- Is failure handled separately from loading?
Exerciseβ
Build a mini router with Overview, Reports, and Team. Make Reports lazy with a slow Promise-backed resource, then add route Suspense, Transition navigation, pending feedback, keyed Team identity, and an Error Boundary.
Interview questionsβ
Beginner: Why might nested Suspense boundaries be better than one root spinner?
Intermediate: How do Transitions change already revealed Suspense content?
Senior: Design loading architecture for a multi-tenant analytics app where shell, tenant identity, charts, and feeds have different loading and reset requirements.
Summaryβ
Referencesβ
- https://react.dev/reference/react/Suspense
- https://react.dev/reference/react/useTransition
- https://react.dev/reference/react/useDeferredValue
- https://react.dev/reference/react/startTransition
Nextβ
Next, go deeper into Transition scheduling and interruption.