<Await> expects to be rendered inside a <React.Suspense> boundary.
Type Declaration
Props
Takes a Promise returned from a loader to be resolved and rendered.
When using a function, the resolved value is provided as the parameter:When using React elements,
useAsyncValue will provide the resolved value:The error element renders instead of the To provide a more contextual error, you can use the If you do not provide an
children when the Promise rejects.useAsyncError hook in a child component:errorElement, the rejected value will bubble up to the nearest route-level ErrorBoundary and be accessible via the useRouteError hook.Examples
Basic Usage with Render Function
With useAsyncValue
With Error Handling
Multiple Deferred Values
Streaming with useAsyncError
Behavior
- Must be rendered inside a
<React.Suspense>boundary - Suspends rendering until the promise resolves
- If the promise rejects and no
errorElementis provided, the error bubbles to the nearest route ErrorBoundary - Works with streaming SSR to progressively enhance the page
- Can be used multiple times for multiple deferred values
Use Cases
- Slow data sources: Load fast data immediately and stream slow data later
- Progressive enhancement: Show critical content first, load optional content in the background
- Improved perceived performance: Don’t block the entire page for slow data
- Waterfall prevention: Load multiple slow resources in parallel
Notes
- The promise is automatically tracked - don’t create new promises on each render
- Combine with streaming SSR for optimal performance
- Use for non-critical data that doesn’t block page render
- Critical data should still be awaited in the loader