React's use() breaks the rules of hooks on purpose
Every hook in React runs under the same contract: call it at the top level of the component, unconditionally, in the same order on every render. The contract exists because React tracks hook state by call order, so a hook inside an if would shift every slot after it. React 19 adds one API that looks like a hook, is named like a hook, and does not follow the contract at all: use(). The docs say it plainly: despite the name, use is not a Hook. It is a render-time read of a resource, a promise or a context, and because it is not a hook it can sit inside a condition or a loop.
a read that can be conditional
With useContext, the read happens at the top of the component, before any early return, on every render. With use(context), the read can sit on the branch that renders. A divider that only reads the theme when it shows:
import { use } from 'react';
import { ThemeContext } from './ThemeContext';
function Divider({ show }: { show: boolean }) {
if (!show) return null;
const theme = use(ThemeContext);
return <hr className={theme === 'dark' ? 'divider-dark' : 'divider-light'} />;
}The saving is one context read on hidden renders, which is nothing. The shape is the point: the component reads what it renders, on the renders where it renders it. The same applies in a loop, where a row can read a context only when that row needs it, instead of the parent reading it for every row up front.
reading a promise during render
The familiar pattern fetches in an effect. The component holds three states (loading, error, data), starts the fetch after the first render, and cleans up so a late response cannot set state on an unmounted component or overwrite a newer one:
import { useEffect, useState } from 'react';
import { fetchAlbums, type Album } from './data';
function Albums() {
const [albums, setAlbums] = useState<Album[] | null>(null);
const [error, setError] = useState<Error | null>(null);
useEffect(() => {
let cancelled = false;
fetchAlbums().then(
(data) => { if (!cancelled) setAlbums(data); },
(err: Error) => { if (!cancelled) setError(err); },
);
return () => { cancelled = true; };
}, []);
if (error) return <p>Failed to load the albums. {error.message}</p>;
if (!albums) return <p>Loading albums...</p>;
return (
<ul>
{albums.map((album) => (
<li key={album.id}>{album.title} ({album.year})</li>
))}
</ul>
);
}That is roughly 15 lines of plumbing around one list, and every data component in the app repeats it. The fetch starts after mount, so the first paint is always the loading branch, even when the data was already on its way.
The use() version splits the jobs. The component reads the promise. A Suspense boundary owns the waiting, and an error boundary owns the failing:
import { Suspense, use } from 'react';
import { ErrorBoundary } from 'react-error-boundary';
import { fetchAlbums } from './data';
export default function AlbumsPage() {
return (
<ErrorBoundary fallback={<p>Failed to load the albums.</p>}>
<Suspense fallback={<p>Loading albums...</p>}>
<Albums />
</Suspense>
</ErrorBoundary>
);
}
function Albums() {
const albums = use(fetchAlbums());
return (
<ul>
{albums.map((album) => (
<li key={album.id}>{album.title} ({album.year})</li>
))}
</ul>
);
}While the promise is pending, Albums suspends and the nearest Suspense fallback shows. When it resolves, React re-renders Albums and use() returns the value. When it rejects, the error propagates to the nearest error boundary. There is no try-catch around use(), and the docs are explicit that use cannot be called inside one; the boundary is the catch.
useEffect the component owns the loading state. With use() the boundary owns it.Press Load albums. The promise is created in the click handler, then read during render.
Same 900ms request in both versions. The useEffect version keeps loading and error state inside the component. The use() version hands both to the boundaries.
One honest note about the demo: this site runs React 18, and use() shipped in React 19, so the demo reads the promise with a 15-line local reader that follows the same contract (throw the promise while it is pending, throw the error when it rejects, return the value when it resolves). In React 19 you delete the reader and hand the promise to use(). The boundaries, the cached promise, and the component shapes stay identical.
the catch: the promise must be cached
use() reads the exact promise you hand it, so the promise has to be the same instance across re-renders. Create it during render and every render hands over a new pending promise: the component suspends, React retries the render from scratch, a new promise is created, and the fallback is all anyone sees. React does not preserve state for a render that suspended before mounting, which is why the retry starts clean. The three shapes that recreate the promise:
use(fetch('/albums')): the fetch call runs during render, one new promise per render.- An async IIFE in render: same problem, a new promise per render.
use(fetchAlbums().then((res) => res.json())):.thenreturns a new promise even whenfetchAlbumsis cached.
The fix is to create the promise before render and reuse the instance. A module-level cache keyed by URL is the smallest version, and it is the pattern the React docs use:
export type Album = { id: number; title: string; year: number };
const cache = new Map<string, Promise<Album[]>>();
export function fetchAlbums(): Promise<Album[]> {
if (!cache.has('/albums')) {
cache.set('/albums', fetch('/albums').then((res) => res.json()));
}
return cache.get('/albums')!;
}Same URL, same promise, every render: 1 request per URL per page load, and after it resolves, use() reads the value synchronously on re-renders, no second suspension. In a real app the promise usually comes from a route loader, an event handler, a Server Component, or a data library cache. The rule is the same in each case: the promise is created outside render, and render only reads it.
where the waiting and the failing live
The tradeoff is where the three states live. The effect version keeps loading and error inside each component: 3 branches per data component, repeated across the app, each with its own cleanup. The use() version moves both to boundaries: 1 fallback per subtree, and the component code shrinks to the happy path. The cost is that boundary placement becomes a design decision. One boundary for the page means one slow list blanks everything under it. My default is one boundary per panel that can load on its own, so panels resolve independently and a failure in one panel stays in that panel.
The context half is quieter but follows the same shape. A conditional context read means a component reads context on the renders that use it, and skips the read on the renders that do not. Read what you render, when you render it.
The pattern to keep: declare the read in render, declare the waiting and the failing in boundaries, and create the promise once, outside render. The component says what it needs, the boundary says what waiting looks like, and the cache says how often the request actually runs. If you have a flow where this breaks down (a waterfall you cannot preload, a fallback that needs per-component detail), let me know where this flow can improve.