Full answer
Suspense lets a component say "I am not ready" while rendering. Older libraries did it by throwing a promise from the render function. In React 19 the supported way is use(promise).
Flow. Render starts. The component calls use(promise). If the promise is pending, React interrupts that component (the rest of the render of that subtree is abandoned), walks up to the nearest <Suspense> boundary and commits its fallback. React keeps track of the promise and subscribes to it. When the promise resolves, React schedules a retry of the suspended render. This time use finds the value and returns it synchronously (React records the promise's status and value on the promise object), the component renders, and the boundary reveals its content. If the promise rejects, use throws the error to the nearest error boundary.
Caching requirement. Each time React retries, it calls your component again. If the component creates the promise itself (use(fetch(...))), each retry creates a new pending promise and suspends again, in an endless loop. The promise must have a stable identity across renders: created in a parent or route loader and passed down, stored in a cache keyed by the request (module-level Map, a data library, a framework cache function), or created in a Server Component (where async/await works). State and refs are not reliable for this, because state of a suspended component that never mounted is not preserved.
Details: libraries mark promises with status fields so that already resolved values can be read synchronously. use can be called conditionally, unlike other hooks, and can also read context. Transitions keep existing content on screen while a retry happens, instead of falling back. React also uses a timing heuristic to avoid flashing fallbacks for very fast resolutions.
The example caches promises by key and counts how many times the component tried to render.
import { Suspense, use } from 'react';
const cache = new Map();
function fetchCourse(id) {
if (!cache.has(id)) {
console.log('starting request for course ' + id);
cache.set(id, new Promise((resolve) => setTimeout(() => resolve('Course ' + id + ' loaded'), 30)));
}
return cache.get(id);
}
let attempts = 0;
function Course({ id }) {
attempts += 1;
console.log('Course render attempt ' + attempts);
return <p>{use(fetchCourse(id))}</p>;
}
export default function App() {
return (
<Suspense fallback={<p>Loading...</p>}>
<Course id={7} />
</Suspense>
);
}The cache makes fetchCourse return the same promise on every attempt, so the request starts once. Attempt 1 suspends. Attempts 2 and 3 are retries after the promise settled, and the request started only once. Without the cache each attempt would start a new request. Output of the run: Course render attempt 1 starting request for course 7 Course render attempt 2 Course render attempt 3
Key points
- A pending use(promise) interrupts the render, shows the nearest fallback and subscribes to the promise.
- When the promise settles, React retries the render, and use returns the value or throws the error.
- The promise needs a stable identity: cache, loader, parent or Server Component.
- Creating the promise inside the suspending component causes an endless loop.
- Transitions keep visible content instead of showing the fallback again.
Common mistakes
- Calling use(fetch(url)) directly in a component.
- Keeping the promise in the state of the component that suspends.
- Forgetting an error boundary for rejected promises.
- Using Suspense without a transition for updates and flashing fallbacks.
- Treating Suspense as a data fetching library rather than a coordination tool.
Follow-ups
- How do frameworks create stable promises for Server Components and client components?
- What does React do when a transition suspends?
- How does a rejected promise reach an error boundary?
Tips
- Describe the flow: pending, fallback, subscribe, retry.
- State the stable-identity rule and why.
- Mention error boundaries and transitions.