← blog
NextjsNovember 27, 2026 · 13 min read

Next.js 16.3 error.js: retry vs reset Aren't Interchangeable

Next.js 16.3 stabilized error.js's retry(), which re-fetches on recovery — reset() only clears state. The real difference, plus a copy-paste cheat sheet.

Parsa Jiravand · Frontend engineer · building bestpractic
Next.js 16.3 error.js: retry vs reset Aren't Interchangeable

Next.js 16.3 shipped something that looks, at first glance, like a naming nitpick: error.js's recovery callback is officially called retry() now, not reset(). It isn't a rename. retry() re-fetches and re-renders your error boundary's children from scratch; reset() only clears the error state and re-renders whatever the client already has. If your error.js's "Try again" button has been wired to reset() since you copied it from a tutorial a couple of years ago, there's a good chance it has never once recovered from a Server Component data error — it just makes the message disappear for a render, then watches it come right back.

This is written against Next.js 16.4.6 (verified against the framework's own docs, as shipped inside the next npm package, November 2026). retry() and its sibling catchError() both landed first as unstable_retry() / unstable_catchError() in 16.2.0, then became stable under their final names in 16.3.0 — so anywhere on 16.3 or later, the stable names are what you should reach for.

By the end of this article you'll be able to:

  • Explain exactly what retry() does differently from reset(), and why only one of them can recover a failed Server Component
  • Draw the actual shape of an error.js boundary — what it wraps, and the two things in its own route segment it does not wrap
  • Know when you need global-error.js instead, and what it costs you (no inherited styles, its own <html>/<body>)
  • Tell not-found.js apart from the new, still-experimental global-not-found.js, and know which one you actually need
  • Use catchError() to put an error boundary around a single component without creating a route-scoped error.tsx file

Who this is for: you're building with the App Router, you already have at least one error.tsx in your project, and you want to know whether it actually works the way you think it does. If Server vs. Client Components are new to you, this series' Server Actions, Mutations & Security episode covers that boundary from the mutation side — worth reading first, not required.

This is almost every error.js you'll find in a tutorial from the last three years, and it still compiles and runs today without a single warning:

TSX
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
// app/dashboard/error.tsx — looks right, recovers nothing 'use client' // Error boundaries must be Client Components export default function Error({ error, reset, }: { error: unknown reset: () => void }) { return ( <div> <h2>Something went wrong!</h2> <button onClick={() => reset()}>Try again</button> </div> ) }

Nothing here is a syntax error, and reset is still a real, supported prop. The gap only shows up at the worst possible time: when the thing that actually failed was a Server Component's data fetch.

TSX
1
2
3
4
5
6
7
// app/dashboard/page.tsx export default async function DashboardPage() { const res = await fetch('https://api.example.com/stats', { cache: 'no-store' }) if (!res.ok) throw new Error('Stats API is down') const stats = await res.json() return <Stats data={stats} /> }

Say /stats glitches for ten seconds and then recovers. A user who clicks a "Try again" button wired to reset() sees the same error, instantly. reset() clears the error boundary's internal state and re-renders its children — but "re-render" here means React re-rendering with whatever it already has on the client. Nothing gets re-fetched. The async Server Component that threw never runs again. The same thrown error (or a fresh one, from the same still-broken dependency) is what comes right back, because the one thing that would have fixed it — asking the server again — never happened.

That's precisely the gap retry() closes.

An error.js file wraps a route segment and everything nested inside it in a React error boundary — but not everything at its own level:

Text
1
2
3
4
5
6
7
8
9
app/dashboard/ ├─ layout.tsx ← NOT wrapped by this segment's error.js ├─ template.tsx ← NOT wrapped either ├─ error.tsx ← the boundary starts here │ (wraps, within this segment and below:) │ ├─ loading.tsx │ ├─ not-found.tsx │ ├─ page.tsx │ └─ nested/layout.tsx (and everything under it)

error.js wraps loading.js, not-found.js, page.js, and any nested layout.js below it — but it does not wrap the layout.js or template.js sitting beside it in the same segment. If the bug is in the layout itself, error.js never gets a chance to catch it; you need global-error.js instead (more on that below).

retry()reset()
Stabilizedv16.3.0 (as unstable_retry in 16.2.0)Always available
What it doesRe-fetches and re-renders the error boundary's childrenClears the error state and re-renders without re-fetching
Recovers a Server Component data errorYes — the Server Component actually runs againNo — nothing is re-fetched, so the same failure resurfaces
When to use itThe default choice for a "Try again" buttonOnly when you deliberately want to clear local error UI without a round trip

The docs are direct about which one to reach for: "In most cases, you should use retry() instead" of reset().

Beyond the boundary itself, three more pieces round out the picture, and each is new or changed recently enough to be worth naming precisely:

  • global-error.js — handles errors in the root layout or template, which an ordinary error.js can never reach. It must define its own <html> and <body>, because it fully replaces the root layout when it activates. As of v15.2.0 it also renders in development, not just production.
  • global-not-found.js (experimental since v15.4.0) — a routing-level 404 for URLs that match no route at all. Unlike not-found.js, which still renders inside your root layout, global-not-found.js skips rendering entirely and returns its own document. It's gated behind an experimental.globalNotFound flag in next.config.ts and, like global-error.js, needs its own <html>/<body> and its own imported styles.
  • catchError() (stable v16.3.0, as unstable_catchError in 16.2.0) — a function from next/error that wraps any part of your component tree in an error boundary, not just a route segment. It's the one to reach for when you want recovery around a single widget without introducing a route-scoped error.tsx. Its own docs note a specific behavior: its retry() re-renders inside a React Transition, which preserves the state of Client Components outside the boundary while it recovers.

Step 1 — the request fails. A request hits /dashboard. The Server Component's fetch to the stats API returns a non-OK response, and the component throws.

Step 2 — the boundary catches it. app/dashboard/error.tsx, a Client Component, mounts and receives { error, retry, reset } as props. In development, error.message carries the real thrown message. In production, Server Component errors are replaced with a generic message plus an error.digest — an automatically generated hash you can match against your server-side logs, specifically so the client never sees details it shouldn't.

Step 3 — the user clicks retry(). Next.js re-fetches and re-renders the error boundary's children — which includes re-running the Server Component that threw. If the stats API has recovered by now, the fallback UI is replaced by the real dashboard. This is the only one of the two functions that can fix this particular class of failure.

Step 4 — compare: the user clicks reset() instead. React clears the boundary's local error state and re-renders its children from what the client already knows. No new request happens. If the underlying cause was server-side, it's either recaught immediately or the user is simply looking at stale output that doesn't reflect why the error went away — because, functionally, it didn't.

Step 5 — the failure moves up a level. Say the throw happens in the root layout itself, not a page. error.js never mounts for this one — a layout-level failure is exactly the case it's defined not to cover. You need app/global-error.tsx, with its own <html> and <body>, since it's replacing the entire root layout.

Step 6 — the URL doesn't match anything at all. This isn't a thrown error and it isn't a notFound() call either — nobody wrote a route for this path. The ordinary app/not-found.tsx still handles this, rendered inside your root layout. But if your app has multiple root layouts (an (admin) and a (shop) route group, say) or a dynamic top-level segment like app/[country]/layout.tsx, there may be no single layout to compose a consistent 404 from. That's what global-not-found.js is for — once you've opted in with the globalNotFound experimental flag, it bypasses rendering and returns its own page for any unmatched URL, independent of which (if any) root layout would otherwise apply.

Step 7 — recovery around one widget, not a whole route. Say a single card on an otherwise-fine page can fail on its own and you don't want a route-wide error.tsx for it. catchError() wraps just that subtree:

TSX
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
// app/custom-error-boundary.tsx 'use client' import { catchError, type ErrorInfo } from 'next/error' function ErrorFallback(props: { title: string }, { error, retry }: ErrorInfo) { const message = error instanceof Error ? error.message : String(error) return ( <div> <h2>{props.title}</h2> <p>{message}</p> <button onClick={() => retry()}>Try again</button> </div> ) } export default catchError(ErrorFallback)
TSX
1
2
3
4
5
6
7
8
9
10
// app/dashboard/page.tsx import ErrorBoundary from '../custom-error-boundary' export default function Page() { return ( <ErrorBoundary title="Stats widget error"> <StatsWidget /> </ErrorBoundary> ) }

  • global-error.js only catches errors in the root layout itself — it's the backstop above everything error.js can reach, not a catch-all for every error in the app. Before v15.2.0 it only rendered in production; it now also shows in development.
  • global-error.js and global-not-found.js don't inherit your app's styles or theme. Both render their own document, bypassing your layout entirely, so an app-level theme toggle (a class or data-theme attribute) never reaches them. The default UI follows the OS color scheme; matching your app's explicit theme means applying it inside the file itself.
  • Error boundaries don't catch errors in event handlers or async code that runs after rendering. They're designed to catch errors during render. A throw inside an onClick handler needs a manual try/catch plus useState to surface — error.js will never see it.
  • An error thrown inside startTransition (from useTransition) does bubble up to the nearest error boundary, even though it's technically running after the initial render.
  • notFound() is special-cased — it never reaches error.js. Calling it throws an internal signal that the router intercepts directly; it renders the nearest not-found.js up the tree, not your error boundary.
  • global-not-found.js must return a complete document. Because it bypasses your layout, it needs its own imported global styles, fonts, and <html>/<body> tags — the same requirement as global-error.js, for the same reason.

  • Wire "Try again" buttons to retry(), not reset(), in every error.js you write from here on — and audit the ones you already have. This is the single highest-value change most App Router codebases can make after reading this.
  • Reserve reset() for the narrow case where you deliberately want to clear local error UI state without a round trip — nothing server-side needs re-checking.
  • Give global-error.js (and global-not-found.js, if you adopt it) their own minimal, self-contained styling. Neither inherits your app shell, so a bare, unstyled fallback is what ships if you forget.
  • Reach for catchError() when you want a boundary around a component, not a route — it saves you from inventing a route-scoped error.tsx just to wrap one widget.
  • Treat global-not-found.js as experimental until it stabilizes. Only reach for it if you genuinely have multiple root layouts or a dynamic root segment that makes a normal layout.js + not-found.js 404 impossible to compose.
  • Log error.digest server-side. It's the one identifier a production user can hand you that maps back to a specific incident in your logs, since the message itself is deliberately generic.

No. They're both still valid props on error.js, but they do different things: retry() re-fetches and re-renders, reset() only clears state and re-renders. Swapping the name without checking the behavior you actually need would be the wrong kind of "fix."

No — reset() is still exported and still works exactly as it always has. It just won't recover from a Server Component data error, which is the most common reason an error boundary fires in the first place.

No. error.js wraps the segment below it, not the layout.js or template.js sitting beside it at the same level. A root layout failure needs global-error.js.

Because it isn't treated as a normal thrown error. notFound() throws an internal signal the router intercepts directly, rendering the nearest not-found.js instead of handing anything to your error boundary.

not-found.js renders for notFound() calls and for unmatched URLs, and it still renders inside your root layout. global-not-found.js (experimental) is for unmatched URLs only, and it bypasses layouts entirely — useful specifically when you have multiple root layouts or a dynamic root segment and can't compose one consistent 404 page any other way.

When the thing that needs recovery is a component, not a route segment — a single widget or card, somewhere inside a page that's otherwise fine.

Only partly. error.js, global-error.js, and global-not-found.js are App Router conventions with no Pages Router equivalent. catchError() does have a Pages Router form, but it only exposes reset() there — retry() is an App Router–only capability, because it depends on re-rendering Server Components.

Text
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
Next.js error & not-found conventions — what catches what, and with what: error.js (Client Component, wraps a route segment) Wraps: loading.js, not-found.js, page.js, nested layout.js (and below) Does NOT wrap: layout.js / template.js at its OWN segment level Props: error, retry, reset retry() → re-fetches + re-renders children (stable v16.3.0, was unstable_retry in v16.2.0) reset() → clears error state only, re-renders WITHOUT re-fetching Use retry() by default. reset() only when nothing needs a round trip. global-error.js (root app/ directory) Catches errors in the ROOT layout/template only — error.js can't reach these Must define its own <html> and <body> Renders in dev too, since v15.2.0 (was production-only before) Does not inherit your app's global styles or theme not-found.js vs global-not-found.js (experimental, v15.4.0+) not-found.js → notFound() calls + unmatched URLs; renders INSIDE root layout global-not-found.js → unmatched URLs only; BYPASSES layouts, own <html>/<body> needs `experimental.globalNotFound: true` in next.config.ts for: multiple root layouts, or a dynamic root segment catchError() (from 'next/error', stable v16.3.0, was unstable_catchError in v16.2.0) Wraps ANY component subtree, not just a route segment App Router: { error, retry, reset } — retry() runs inside a Transition, preserving Client Component state OUTSIDE the boundary Pages Router: { error, reset } only — no retry() notFound() is special-cased: it never reaches error.js, the router renders not-found.js directly. Errors in event handlers / post-render async code are NOT caught by any of these — catch them manually with try/catch + useState.

Runs right in your browser — poke at it and watch the concept react live.

  • retry() (stable since v16.3.0) re-fetches and re-renders an error boundary's children; reset() only clears local error state. They are not interchangeable, and most "Try again" buttons should be calling retry().
  • An error.js boundary wraps everything below it in its segment, but never the layout.js/template.js sitting beside it — that gap belongs to global-error.js.
  • global-not-found.js (experimental since v15.4.0) and catchError() (stable since v16.3.0) round out the toolbox for the cases a route-scoped error.js was never going to reach.

If your error.js files have been quietly shipping reset() since before any of this existed, you're not alone, and nothing is currently broken in a way that throws a warning. But the next time a Server Component's data dependency hiccups for a few seconds, the difference between those two function calls is the difference between a "Try again" button that actually works and one that just plays dead and comes back.

Instant feedback, a hint on every question, and an explanation for each answer — right or wrong.


🚀 Want more like this? Every guide, playground, and quiz lives on bestpractic.org — open it and sign up free so the next one finds you.

Thanks for reading! Let's stay connected:

Keep reading

One post a day, in your inbox

Each one with a runnable playground and a quiz. No pitch, no digest, unsubscribe in one click.

0 comments

Sign in to join the discussion, like comments, and save articles for later.