Suspense

A React component that shows a fallback, such as a spinner or skeleton, while components inside it are waiting for something to load.

In more detail

A component suspends when it reads a pending promise with use or is a lazy component whose code has not loaded. React then shows the fallback of the nearest Suspense above it and retries when the promise resolves. Nesting several boundaries lets fast parts of the page appear before slow ones.

Examples

<Suspense fallback={<CardSkeleton />}>
  <Recommendations />
</Suspense>
<Suspense fallback={<Spinner />}><Profile /></Suspense>

Related terms

Taught in

References