Capítulo 37 de 57
By returning an unawaited promise from a route's loader, the router can render the next route as soon as the awaited (fast) data resolves, while slower, non-critical data streams in later and is consumed in the component via the Await component (or React 19's use() hook).
Await component: resolves a deferred promise by suspending the nearest suspense boundary until it settles, then renders children as a function receiving the resolved data; on rejection, it throws the serialized error to the nearest error boundary.fallback prop: the loading UI shown by Await while its promise is pending.use() hook: an alternative to Await for resolving promises directly in a React component.queryClient.prefetchQuery (unawaited) for slow data and queryClient.ensureQueryData (awaited) for fast data; components then use useSuspenseQuery wrapped in a <Suspense> boundary for the slow data.<Await> triggers suspense boundaries so the server can stream HTML incrementally; the client receives placeholder promises that resolve as streamed data arrives via inline script tags.// src/routes/posts.$postId.tsx
export const Route = createFileRoute('/posts/$postId')({
loader: async () => {
const slowDataPromise = fetchSlowData() // not awaited
const fastData = await fetchFastData()
return { fastData, deferredSlowData: slowDataPromise }
},
component: PostIdComponent,
})
function PostIdComponent() {
const { deferredSlowData, fastData } = Route.useLoaderData()
return (
<Await promise={deferredSlowData} fallback={<div>Loading...</div>}>
{(data) => <div>{data}</div>}
</Await>
)
}
Await.pendingComponent (see Ch 36).Await entirely and use prefetchQuery/useSuspenseQuery with a manual <Suspense> boundary instead.