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.

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 fromreset(), and why only one of them can recover a failed Server Component - Draw the actual shape of an
error.jsboundary — what it wraps, and the two things in its own route segment it does not wrap - Know when you need
global-error.jsinstead, and what it costs you (no inherited styles, its own<html>/<body>) - Tell
not-found.jsapart from the new, still-experimentalglobal-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-scopederror.tsxfile
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.
- The wrong way: wiring "Try again" to reset()
- The mental model: two recovery functions, two different operations
- Staged walkthrough
- Edge cases
- Best practices
- FAQ
- Cheat sheet
- Key takeaways
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:
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.
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:
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() | |
|---|---|---|
| Stabilized | v16.3.0 (as unstable_retry in 16.2.0) | Always available |
| What it does | Re-fetches and re-renders the error boundary's children | Clears the error state and re-renders without re-fetching |
| Recovers a Server Component data error | Yes — the Server Component actually runs again | No — nothing is re-fetched, so the same failure resurfaces |
| When to use it | The default choice for a "Try again" button | Only 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 ordinaryerror.jscan never reach. It must define its own<html>and<body>, because it fully replaces the root layout when it activates. As ofv15.2.0it also renders in development, not just production.global-not-found.js(experimental sincev15.4.0) — a routing-level 404 for URLs that match no route at all. Unlikenot-found.js, which still renders inside your root layout,global-not-found.jsskips rendering entirely and returns its own document. It's gated behind anexperimental.globalNotFoundflag innext.config.tsand, likeglobal-error.js, needs its own<html>/<body>and its own imported styles.catchError()(stablev16.3.0, asunstable_catchErrorin16.2.0) — a function fromnext/errorthat 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-scopederror.tsx. Its own docs note a specific behavior: itsretry()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:
global-error.jsonly catches errors in the root layout itself — it's the backstop above everythingerror.jscan reach, not a catch-all for every error in the app. Beforev15.2.0it only rendered in production; it now also shows in development.global-error.jsandglobal-not-found.jsdon'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 ordata-themeattribute) 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
throwinside anonClickhandler needs a manualtry/catchplususeStateto surface —error.jswill never see it. - An error thrown inside
startTransition(fromuseTransition) does bubble up to the nearest error boundary, even though it's technically running after the initial render. notFound()is special-cased — it never reacheserror.js. Calling it throws an internal signal that the router intercepts directly; it renders the nearestnot-found.jsup the tree, not your error boundary.global-not-found.jsmust return a complete document. Because it bypasses your layout, it needs its own imported global styles, fonts, and<html>/<body>tags — the same requirement asglobal-error.js, for the same reason.
- Wire "Try again" buttons to
retry(), notreset(), in everyerror.jsyou 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(andglobal-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-scopederror.tsxjust to wrap one widget. - Treat
global-not-found.jsas experimental until it stabilizes. Only reach for it if you genuinely have multiple root layouts or a dynamic root segment that makes a normallayout.js+not-found.js404 impossible to compose. - Log
error.digestserver-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.
Runs right in your browser — poke at it and watch the concept react live.
retry()(stable sincev16.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 callingretry().- An
error.jsboundary wraps everything below it in its segment, but never thelayout.js/template.jssitting beside it — that gap belongs toglobal-error.js. global-not-found.js(experimental sincev15.4.0) andcatchError()(stable sincev16.3.0) round out the toolbox for the cases a route-scopederror.jswas 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.
Think it clicked? Take the 8-question quiz →
Instant feedback, a hint on every question, and an explanation for each answer — right or wrong.
- Next.js Cache Components Explained (with Cheat Sheet)
- Next.js 16 Image: priority Deprecated, quality Now Allowlisted
- Next.js Server Actions: Mutations & Security (Cheat Sheet)
🚀 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:
- ⭐ GitHub — follow me and star the projects: github.com/parsajiravand
- 💬 Discord — join the frontend best-practices community: discord.gg/d9KRhuAwQ
- 📸 Instagram — frontend best practices, daily: @bestpractice___
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.