useAsyncValue
Returns the resolved promise value from the closest <Await> component.
Return Value
unknown
The resolved value from the nearest
<Await> component’s promise. The type will match whatever your promise resolves to.Type Declaration
Usage Examples
Basic Usage with Await
Displaying User Data
Multiple Deferred Values
Type Safety
Using TypeScript
With Generic Type Inference
Common Patterns
Nested Await Components
Error Handling
For error handling with deferred data, useuseAsyncError or provide an errorElement prop to the <Await> component:
Notes
- This hook must be used within a component rendered by an
<Await>component - The hook returns the resolved value, not the promise itself
- Available in Framework and Data modes only
- The returned value is
unknownby default - use type assertions for type safety - This hook does not handle errors - use
useAsyncErrororerrorElementfor error handling
Related
useAsyncError- Get the error from a rejected promise<Await>- Component for rendering deferred datadefer- Utility for creating deferred data- Deferred Data Guide - Learn about streaming with deferred data