Skip to main content
Suspense lets you display a fallback UI while its children are loading. It enables components to “suspend” rendering while waiting for asynchronous data to load.

Type

Internally, Suspense is represented by the symbol Symbol.for('react.suspense') (the value of REACT_SUSPENSE_TYPE in React’s source).

Props

ReactNode
required
The actual UI you intend to render. If children suspends while rendering, the Suspense boundary will switch to rendering the fallback.
ReactNode
required
An alternate UI to render in place of the actual UI if it hasn’t finished loading. Any valid React node is accepted, though in practice, a fallback is a lightweight placeholder view such as a loading spinner or skeleton.The fallback will automatically be replaced by the children when the data is ready.

Usage

Basic Example

Multiple Suspense Boundaries

You can have multiple Suspense boundaries at different levels:
How it works:
  • Each section can suspend independently
  • Inner Suspense boundaries catch suspensions first
  • If multiple children suspend, only the nearest Suspense boundary’s fallback is shown

Nested Suspense

Suspense boundaries can be nested to create cascading loading states:

What Can Suspend?

Suspense works with:

1. React.lazy() - Code Splitting

2. Data Fetching with Frameworks

Frameworks like Relay, Next.js, and Remix support Suspense for data fetching:

3. React 19+ use() Hook

4. Server Components (React Server Components)

Showing Content as it Loads

Use multiple Suspense boundaries to show content progressively:
Loading sequence:
  1. Header and Footer show immediately
  2. MainSkeleton shows while MainContent loads
  3. MainContent appears when ready
  4. CommentsSkeleton shows while Comments load
  5. Comments appear when ready

Error Boundaries

Suspense works together with Error Boundaries to handle errors during loading:
What happens:
  • If DataComponent suspends → <Loading /> is shown
  • If DataComponent throws an error → <ErrorPage /> is shown
  • If DataComponent succeeds → component renders normally

Combined Pattern

Transitions and Suspense

Use transitions to avoid hiding already visible content:
Benefits:
  • The current tab stays visible while the new tab loads
  • A spinner indicates loading is happening
  • Better user experience than showing fallback immediately

Preventing Unwanted Fallbacks

Problem: Fallback Flashing

If data loads quickly, showing a loading spinner can create a jarring flash:

Solution: Use Transitions

How it helps:
  • The old content stays visible during refresh
  • The button shows loading state instead
  • Fallback only shows for initial load, not refreshes

Use Cases

Code Splitting

Data Fetching

Parallel Loading

Waterfall Prevention

Start requests before rendering:

Best Practices

1. Use Meaningful Fallbacks

2. Place Boundaries Strategically

3. Handle Errors

4. Use Transitions for Updates

Common Pitfalls

Pitfall #1: Creating promises during render
Pitfall #2: Suspense without Error Boundary
Pitfall #3: Too many Suspense boundaries
Server-Side Rendering:Suspense works with SSR to stream HTML to the client. Components that suspend are rendered on the server and sent when ready, allowing the browser to show content progressively.