---
title: "How do I read a promise or context with the use() hook?"
description: "React 19's use() reads a promise or a context during render. Learn how it suspends with Suspense, why the promise must be stable, and how it differs from useContext."
url: https://www.danny.engineering/answer/react/how-do-i-read-a-promise-or-context-with-the-use-hook
author: Danny
published: 2026-11-27T00:00:00.000Z
updated: 2026-11-27T17:23:00.000Z
tags: ["React"]
---

# How do I read a promise or context with the use() hook?

## The short answer


`use` is a React 19 API that reads a value from a promise or a context while a component renders. Given a promise, the component suspends until it resolves and the nearest `Suspense` boundary shows its fallback. Given a context, it works like `useContext`, except that you can call it inside conditions and loops.


```typescript
import { use, Suspense } from 'react';

function Comments({ commentsPromise }: { commentsPromise: Promise<Comment[]> }) {
  const comments = use(commentsPromise);
  return comments.map((c) => <p key={c.id}>{c.text}</p>);
}

// higher up the tree
<Suspense fallback={<p>Loading comments...</p>}>
  <Comments commentsPromise={commentsPromise} />
</Suspense>
```


## Why it happens


Before React 19, reading async data in a component meant an effect, a loading flag and a state update, or a data library that handled Suspense for you. `use` builds that into React.


When you call `use(promise)` and the promise is still pending, React pauses rendering that component and shows the closest `Suspense` fallback. When the promise resolves, React renders the component again and `use` returns the value. If the promise rejects, the nearest error boundary catches the error.


The docs call `use` an API rather than a hook because it does not follow every hook rule. It must still be called inside a component or a hook, but it can sit inside an `if` statement or a loop. That is the main reason to prefer it over `useContext`.


## How to fix it


### Create the promise in a Server Component and pass it down


This is the pattern React recommends. The Server Component starts the request without awaiting it, so the page can stream, and the Client Component reads the result:


```typescript
// app/posts/[id]/page.tsx (Server Component)
import { Suspense } from 'react';
import { Comments } from './comments';

export default async function Page({ params }: { params: Promise<{ id: string }> }) {
  const { id } = await params;
  const commentsPromise = getComments(id); // no await

  return (
    <Suspense fallback={<p>Loading comments...</p>}>
      <Comments commentsPromise={commentsPromise} />
    </Suspense>
  );
}
```


```typescript
// app/posts/[id]/comments.tsx
'use client';

import { use } from 'react';

export function Comments({ commentsPromise }: { commentsPromise: Promise<Comment[]> }) {
  const comments = use(commentsPromise);
  return (
    <ul>
      {comments.map((c) => (
        <li key={c.id}>{c.text}</li>
      ))}
    </ul>
  );
}
```


The resolved value crosses from server to client, so it must be serialisable.


### Cache the promise in client-only apps


A promise created during render is a new promise on every render, so the component suspends again and again. Create it once, outside render, and reuse it:


```typescript
const userCache = new Map<string, Promise<User>>();

export function getUser(id: string) {
  if (!userCache.has(id)) {
    userCache.set(id, fetch(`/api/users/${id}`).then((res) => res.json()));
  }
  return userCache.get(id)!;
}
```


In a real app, a data library with Suspense support or your framework's data loading usually handles this for you.


### Handle errors


Wrap the component in an error boundary, or give the promise a fallback value before passing it down:


```typescript
const commentsPromise = getComments(id).catch(() => []);
```


### Read context conditionally


```typescript
function Heading({ children, plain }: { children: React.ReactNode; plain?: boolean }) {
  if (plain) {
    return <h2>{children}</h2>;
  }
  const theme = use(ThemeContext);
  return <h2 style={{ color: theme.accent }}>{children}</h2>;
}
```


## Common pitfalls

- Calling `fetch` inside the component body and passing the result to `use`. That creates a new promise every render. Create it in a Server Component, a loader or a cache.
- Leaving out a `Suspense` boundary. React falls back to the nearest one above, which may hide far more of the page than you meant.
- Wrapping `use` in `try...catch`. React does not allow it. Use an error boundary or the promise's `catch` method instead.
- Calling `use` in an event handler or a plain function. Like hooks, it only works during render, in a component or a custom hook.
- Reaching for `use` in Server Components. There you can simply `await` the promise.

## Related reading

- [React: use](https://react.dev/reference/react/use)
- [React: Suspense](https://react.dev/reference/react/Suspense)
