Skip to content

Suspense

In one line

Suspense is a React component that shows a fallback UI while its children are loading — used with lazy loading and data fetching.

In simple words

<Suspense> lets you specify a loading indicator (fallback) for a part of the UI that isn't ready yet. When a child "suspends" — because it's lazy-loading code or fetching data — React shows the fallback instead, and swaps in the real content when it's ready.

<Suspense fallback={<Spinner />}><MyComponent /></Suspense> — if MyComponent suspends, the Spinner shows. When MyComponent is ready, it renders.

Suspense works with React.lazy for code splitting and, in React 18+, with concurrent features like use() for data fetching. You can nest Suspense boundaries to show different fallbacks for different parts of the page.

Example

jsx
<Suspense fallback={<div>Loading chart...</div>}>
  <LazyChart />
</Suspense>

While LazyChart's code is downloading, the 'Loading chart...' fallback is shown. Once loaded, the chart renders.

Related terms

Related Resources

Related Lessons

Decode error messages

Plain-English explanations of common errors — what they mean, why they happen, and how to fix them.

View errors

← Back to glossary