Suspense Overview
Suspense coordinates loading UI for lazy components and data: boundaries, fallbacks, and what it does not catch.
- react
- suspense-overview
Suspense lets a child announce it is not ready (usually by throwing a promise internally) so React can show the nearest fallback instead of blocking the whole tree ad hoc. You place boundaries where loading UI should appear.
Lazy code loading
const Map = lazy(() => import('./Map'));
<Suspense fallback={<div className="skeleton map" />}>
<Map />
</Suspense>
See code splitting.
Data and frameworks
In frameworks with Suspense-aware data (Next App Router RSC streaming, Relay, some routers), components can suspend while data loads. You still need boundaries:
// Next.js
<Suspense fallback={<ReviewsSkeleton />}>
<Reviews productId={id} />
</Suspense>
Without a boundary, the nearest parent (or the whole page) waits. See streaming in Next.
Mental model
- Child suspends.
- React finds the closest Suspense boundary.
- Shows that boundary’s
fallback. - When ready, renders the child and commits.
Nested boundaries let fast shell paint while slow panels stream in.
Not an error boundary
Suspense handles loading, not errors. Failed fetches and render throws need error boundaries / error.tsx. Often you wrap both:
<ErrorBoundary>
<Suspense fallback={<Spinner />}>
<Profile />
</Suspense>
</ErrorBoundary>
Interview out-loud
“Suspense shows a fallback while children are loading code or data via a framework that supports it. I place boundaries around independent panels so the shell can render early. Errors still need error boundaries; Suspense is not a try/catch for failures.”
Related on this site
- Code Splitting with React.lazy
- Error Boundaries
- Streaming and Suspense Boundaries
- Concurrent Features Overview
Further reading
Edge cases worth rehearsing
Interviewers and production incidents cluster around the same edges: first render versus update, empty and loading states, Strict Mode double setup, concurrent interruptions, and what happens when identity (key, route params, user id) changes mid-edit. Walk one concrete user journey end-to-end — open, edit, navigate away, come back — and say which state survives.
Prefer fixing data flow and ownership before reaching for memoization or micro-optimizations. Prefer event handlers over effects when a user action is the trigger. Prefer deriving values during render over mirroring props into state. Prefer stable list keys from business ids. Measure with the profiler when performance is the claim.
When you cite an API, mention one failure mode: abort on unmount, serializable props across server/client boundaries, focus restoration for dialogs, or cache invalidation after a mutation. Specific beats generic every time.
Quick self-test
Explain the concept in 60 seconds, write a minimal code sample from memory, name one footgun, and point to the primary docs. If any of those fail, reread the worked example and rebuild it in a scratch file until the model sticks under interview pressure.
Edge cases worth rehearsing
Interviewers and production incidents cluster around the same edges: first render versus update, empty and loading states, Strict Mode double setup, concurrent interruptions, and what happens when identity (key, route params, user id) changes mid-edit. Walk one concrete user journey end-to-end — open, edit, navigate away, come back — and say which state survives.
Prefer fixing data flow and ownership before reaching for memoization or micro-optimizations. Prefer event handlers over effects when a user action is the trigger. Prefer deriving values during render over mirroring props into state. Prefer stable list keys from business ids. Measure with the profiler when performance is the claim.
When you cite an API, mention one failure mode: abort on unmount, serializable props across server/client boundaries, focus restoration for dialogs, or cache invalidation after a mutation. Specific beats generic every time.
Related guides
- Accessibility Patterns in ReactPractical React a11y: labels, focus management, keyboard, live regions, and composition patterns that stay accessible.
- Avoid Prop Drilling with CompositionStop threading props through intermediates: children slots, inversion of control, and when context is the right escape hatch.
- Batching State UpdatesHow React 18+ batches setState in events, timeouts, and promises: when updates flush and why double setState still works.
- Children Prop PatternsUsing children and slot props for flexible APIs: wrappers, compound components, and when to prefer explicit props.
- Client Component BoundariesWhere to put use client: push interactivity to leaves, serializable props, and children as server slots.