---
title: Await
---
# Await
[MODES: framework, data]
## Summary
[Reference Documentation ↗](https://api.reactrouter.com/v7/functions/react_router.Await.html)
Used to render promise values with automatic error handling.
**Note:** `` expects to be rendered inside a [``](https://react.dev/reference/react/Suspense)
```tsx
import { Await, useLoaderData } from "react-router";
export async function loader() {
// not awaited
const reviews = getReviews();
// awaited (blocks the transition)
const book = await fetch("/api/book").then((res) => res.json());
return { book, reviews };
}
function Book() {
const { book, reviews } = useLoaderData();
return (
{book.title}
{book.description}
}>
Could not load reviews 😬
}
children={(resolvedReviews) => (
)}
/>
);
}
```
## Signature
```tsx
function Await({
children,
errorElement,
resolve,
}: AwaitProps)
```
## Props
### children
When using a function, the resolved value is provided as the parameter.
```tsx [2]
{(resolvedReviews) => }
```
When using React elements, [`useAsyncValue`](../hooks/useAsyncValue) will provide the
resolved value:
```tsx [2]
function Reviews() {
const resolvedReviews = useAsyncValue();
return ...
;
}
```
### errorElement
The error element renders instead of the `children` when the [`Promise`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise)
rejects.
```tsx
Oops}
resolve={reviewsPromise}
>
```
To provide a more contextual error, you can use the [`useAsyncError`](../hooks/useAsyncError) in a
child component
```tsx
}
resolve={reviewsPromise}
>
function ReviewsError() {
const error = useAsyncError();
return
Error loading reviews: {error.message}
;
}
```
If you do not provide an `errorElement`, the rejected value will bubble up
to the nearest route-level [`ErrorBoundary`](../../start/framework/route-module#errorboundary)
and be accessible via the [`useRouteError`](../hooks/useRouteError) hook.
### resolve
Takes a [`Promise`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise)
returned from a [`loader`](../../start/framework/route-module#loader) to be
resolved and rendered.
```tsx
import { Await, useLoaderData } from "react-router";
export async function loader() {
let reviews = getReviews(); // not awaited
let book = await getBook();
return {
book,
reviews, // this is a promise
};
}
export default function Book() {
const {
book,
reviews, // this is the same promise
} = useLoaderData();
return (
{book.title}
{book.description}
}>
);
}
```