React 19.x: Actions, forms and Server Components · senior
The use() API and browser()
use(resource) reads a promise (suspending until it resolves) or a context, and unlike hooks it can be called inside conditions and loops; the promise must come from a cache, a framework or a Server Component, never be created during render.
Explain it out loud
Explain it out loud to an AI interviewer that follows up, and see where your answer is thin.
Practise by voiceThe notes
What you must know
const data = use(promise)suspends until the promise resolves; rejection goes to the nearest error boundary. Do not wrapusein try/catch.use(ThemeContext)reads context and can be called after an early return or inside anif, whichuseContextcannot.- Promises must be cached so the same instance is reused across renders. React warns "A component was suspended by an uncached promise".
- Streaming pattern: a Server Component starts a fetch without awaiting and passes the promise to a Client Component inside
<Suspense>; the client callsuse(promise). The resolved value must be serializable. - Do not read
promise.statusyourself to skipuse; let React handle it. use(reading context) is not supported in Server Components.- React 19.3:
use(browser())fromreact-domsuspends on the server (fallback goes into the HTML) and renders normally on the client after hydration. It can be called conditionally, for example only when noinitialDataexists.
The red pen
Common traps: mistake → fix
Mistake: "
use(fetch(url))in a client component"Fix: a new promise every render; it keeps suspending.
Mistake: "use is just useContext with a new name"
Fix: it also reads promises and can be conditional.
Mistake: "Wrap use() in try/catch to handle errors"
Fix: use an error boundary.
Easy to hard
Questions interviewers ask, easy to hard
- What does
usedo that other hooks cannot? - Why must the promise be cached or stable?
- When would you pass a promise from a Server Component to a Client Component and
useit? - How do you handle a rejected promise?
- What is
use(browser())for?
Explain it out loud
Explain it out loud to an AI interviewer that follows up, and see where your answer is thin.
Practise by voiceYour first interview is free
Sign up and start with a 15-minute interview with the full report, and an English conversation. No card needed.