[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"verticals":3,"quiz-nextjs-weekly-error-retry-vs-reset":44,"search-suggestions":60,"quiz-article-nextjs-weekly-error-retry-vs-reset":109,"path-membership-nextjs-weekly-error-retry-vs-reset":517},[4,20,32],{"id":5,"slug":6,"name":7,"tagline":8,"description":9,"accentFrom":10,"accentTo":11,"icon":12,"defaultLocale":13,"locales":14,"features":16,"position":19},"019fe637-3d33-714b-b57f-23e163ffca0c","dev","Web Development","Read it. Run it. Prove it.","A post a day on modern web development — most with an editable playground and a quiz that explains every answer. Free, no account needed.","violet-500","cyan-400","◇","en",[13,15],"fa",{"courses":17,"paths":17,"articles":17,"exams":18,"flashcards":18,"packages":17,"community":17,"certificates":17,"teams":17,"commerce":17},true,false,0,{"id":21,"slug":22,"name":23,"tagline":24,"description":25,"accentFrom":26,"accentTo":10,"icon":27,"defaultLocale":13,"locales":28,"features":30,"position":31},"019fe637-3dc2-754c-8657-0f175bfee7c6","lang","Languages","Learn a language the way you learn a codebase.","Grammar explained the way good documentation explains an API — one idea at a time, each with a quiz.","amber-400","⌘",[13,15,29],"es",{"courses":18,"paths":18,"articles":17,"exams":18,"flashcards":17,"packages":18,"community":17,"certificates":17,"teams":18,"commerce":18},2,{"id":33,"slug":34,"name":35,"tagline":36,"description":37,"accentFrom":38,"accentTo":39,"icon":40,"defaultLocale":13,"locales":41,"features":42,"position":43},"7b3c16f2-931d-410e-802e-e1fa4edab7de","soft","Soft Skills","The half of the job nobody wrote documentation for.","Weekly, on the parts of working life that decide more than your code does — first weeks, meetings, interviews, promotions, and the people around you. Written from what actually happens, and recorded as a podcast you can listen to on the walk.","emerald-400","teal-300","◉",[13],{"courses":18,"paths":18,"articles":17,"exams":18,"flashcards":18,"packages":18,"community":17,"certificates":18,"teams":18,"commerce":18},3,{"id":45,"slug":46,"kind":47,"title":48,"description":49,"config":50,"verticalId":5,"vertical":55,"course":52,"_count":56,"access":57,"attempts":59,"questionCount":51},"01a1df1b-209e-77d9-ade3-4df46a2375e0","nextjs-weekly-error-retry-vs-reset","PRACTICE_QUIZ","Next.js error.js: retry() vs reset()","Test yourself on what retry() and reset() actually do, what error.js's boundary covers, and where global-error.js, global-not-found.js, and catchError() fit in.",{"questionCount":51,"timeLimitSec":52,"shuffleQuestions":18,"shuffleOptions":17,"negativeMarking":19,"passScorePct":53,"maxAttempts":52,"revealAnswers":54,"allowFlagging":18,"allowBacktracking":17},8,null,70,"AFTER_SUBMIT",{"slug":6,"name":7},{"questions":51},{"allowed":17,"reason":58},"FREE",[],[61,65,69,73,77,81,85,89,93,97,101,105],{"slug":62,"name":63,"articles":64},"webdev","Webdev",195,{"slug":66,"name":67,"articles":68},"javascript","Javascript",156,{"slug":70,"name":71,"articles":72},"frontend","Frontend",103,{"slug":74,"name":75,"articles":76},"tutorial","Tutorial",85,{"slug":78,"name":79,"articles":80},"css","Css",56,{"slug":82,"name":83,"articles":84},"typescript","Typescript",36,{"slug":86,"name":87,"articles":88},"performance","Performance",33,{"slug":90,"name":91,"articles":92},"programming","Programming",26,{"slug":94,"name":95,"articles":96},"react","React",23,{"slug":98,"name":99,"articles":100},"node","Node",19,{"slug":102,"name":103,"articles":104},"browser","Browser",18,{"slug":106,"name":107,"articles":108},"nextjs","Nextjs",13,{"id":110,"slug":46,"title":111,"subtitle":52,"excerpt":112,"coverUrl":113,"locale":13,"readingMinutes":108,"publishedAt":114,"viewCount":115,"likeCount":19,"commentCount":19,"author":116,"vertical":121,"topic":122,"tags":123,"_count":128,"playground":130,"body":132,"bodyMd":448,"seo":449,"translationGroupId":451,"series":452,"podcastUrl":52,"verticalId":5,"thread":508,"assessments":510,"translations":513,"quiz":515},"01a1df1b-203c-7390-aa4a-3c6b678e7abe","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.","\u002Fmedia\u002Fcovers\u002Fnextjs-weekly-error-retry-vs-reset.png","2026-11-27T11:42:24.474Z",20,{"id":117,"name":118,"username":119,"avatarUrl":52,"headline":120},"019fe637-3c25-7088-9034-39c9f15dc3c8","Parsa Jiravand","parsa","Frontend engineer · building bestpractic",{"slug":6,"name":7,"accentFrom":10,"accentTo":11},{"slug":106,"name":107},[124,125,126,127],{"slug":106,"name":107,"color":52},{"slug":94,"name":95,"color":52},{"slug":62,"name":63,"color":52},{"slug":74,"name":75,"color":52},{"assessments":129},1,{"slug":46,"title":131},"Next.js error.js: retry() vs reset() — interactive playground",{"blocks":133,"version":129},[134,138,141,146,149,158,161,164,175,179,182,188,191,195,198,201,204,208,211,216,219,223,247,250,253,256,262,265,268,271,274,277,280,283,286,290,294,297,306,309,318,321,325,328,332,335,339,342,346,349,353,356,360,363,366,369,372,376,379,382,385,388,391,394,400,403,406,409,412,415,418,421,424,430,433,436,439,442],{"id":135,"html":136,"type":137},"b1","\u003Cp>Next.js 16.3 shipped something that looks, at first glance, like a naming nitpick: \u003Ccode>error.js\u003C\u002Fcode>&#39;s recovery callback is officially called \u003Ccode>retry()\u003C\u002Fcode> now, not \u003Ccode>reset()\u003C\u002Fcode>. It isn&#39;t a rename. \u003Ccode>retry()\u003C\u002Fcode> re-fetches and re-renders your error boundary&#39;s children from scratch; \u003Ccode>reset()\u003C\u002Fcode> only clears the error state and re-renders whatever the client already has. If your \u003Ccode>error.js\u003C\u002Fcode>&#39;s &quot;Try again&quot; button has been wired to \u003Ccode>reset()\u003C\u002Fcode> since you copied it from a tutorial a couple of years ago, there&#39;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.\u003C\u002Fp>","paragraph",{"id":139,"html":140,"type":137},"b2","\u003Cp>This is written against \u003Cstrong>Next.js 16.4.6\u003C\u002Fstrong> (verified against the framework&#39;s own docs, as shipped inside the \u003Ccode>next\u003C\u002Fcode> npm package, November 2026). \u003Ccode>retry()\u003C\u002Fcode> and its sibling \u003Ccode>catchError()\u003C\u002Fcode> both landed first as \u003Ccode>unstable_retry()\u003C\u002Fcode> \u002F \u003Ccode>unstable_catchError()\u003C\u002Fcode> in \u003Cstrong>16.2.0\u003C\u002Fstrong>, then became stable under their final names in \u003Cstrong>16.3.0\u003C\u002Fstrong> — so anywhere on 16.3 or later, the stable names are what you should reach for.\u003C\u002Fp>",{"id":142,"html":143,"text":144,"type":145,"level":31},"b3","What you&#39;ll learn","What you'll learn","heading",{"id":147,"html":148,"type":137},"b4","\u003Cp>By the end of this article you&#39;ll be able to:\u003C\u002Fp>",{"id":150,"type":151,"items":152,"ordered":18},"b5","list",[153,154,155,156,157],"Explain exactly what \u003Ccode>retry()\u003C\u002Fcode> does differently from \u003Ccode>reset()\u003C\u002Fcode>, and why only one of them can recover a failed Server Component","Draw the actual shape of an \u003Ccode>error.js\u003C\u002Fcode> boundary — what it wraps, and the two things in its own route segment it does \u003Cem>not\u003C\u002Fem> wrap","Know when you need \u003Ccode>global-error.js\u003C\u002Fcode> instead, and what it costs you (no inherited styles, its own \u003Ccode>&lt;html&gt;\u003C\u002Fcode>\u002F\u003Ccode>&lt;body&gt;\u003C\u002Fcode>)","Tell \u003Ccode>not-found.js\u003C\u002Fcode> apart from the new, still-experimental \u003Ccode>global-not-found.js\u003C\u002Fcode>, and know which one you actually need","Use \u003Ccode>catchError()\u003C\u002Fcode> to put an error boundary around a single component without creating a route-scoped \u003Ccode>error.tsx\u003C\u002Fcode> file",{"id":159,"html":160,"type":137},"b6","\u003Cp>\u003Cstrong>Who this is for:\u003C\u002Fstrong> you&#39;re building with the App Router, you already have at least one \u003Ccode>error.tsx\u003C\u002Fcode> 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&#39; \u003Ca href=\"https:\u002F\u002Fdev.to\u002Fparsajiravand\u002Fnextjs-server-actions-mutations-security-cheat-sheet-b63\">Server Actions, Mutations &amp; Security\u003C\u002Fa> episode covers that boundary from the mutation side — worth reading first, not required.\u003C\u002Fp>",{"id":162,"html":163,"text":163,"type":145,"level":31},"b7","Contents",{"id":165,"type":151,"items":166,"ordered":18},"b8",[167,168,169,170,171,172,173,174],"\u003Ca href=\"#the-wrong-way-wiring-try-again-to-reset\">The wrong way: wiring &quot;Try again&quot; to reset()\u003C\u002Fa>","\u003Ca href=\"#the-mental-model-two-recovery-functions-two-different-operations\">The mental model: two recovery functions, two different operations\u003C\u002Fa>","\u003Ca href=\"#staged-walkthrough\">Staged walkthrough\u003C\u002Fa>","\u003Ca href=\"#edge-cases\">Edge cases\u003C\u002Fa>","\u003Ca href=\"#best-practices\">Best practices\u003C\u002Fa>","\u003Ca href=\"#faq\">FAQ\u003C\u002Fa>","\u003Ca href=\"#cheat-sheet\">Cheat sheet\u003C\u002Fa>","\u003Ca href=\"#key-takeaways\">Key takeaways\u003C\u002Fa>",{"id":176,"html":177,"text":178,"type":145,"level":31},"b9","The wrong way: wiring &quot;Try again&quot; to reset()","The wrong way: wiring \"Try again\" to reset()",{"id":180,"html":181,"type":137},"b10","\u003Cp>This is almost every \u003Ccode>error.js\u003C\u002Fcode> you&#39;ll find in a tutorial from the last three years, and it still compiles and runs today without a single warning:\u003C\u002Fp>",{"id":183,"code":184,"type":185,"language":186,"highlight":187},"b11","\u002F\u002F app\u002Fdashboard\u002Ferror.tsx — looks right, recovers nothing\n'use client' \u002F\u002F Error boundaries must be Client Components\n\nexport default function Error({\n  error,\n  reset,\n}: {\n  error: unknown\n  reset: () => void\n}) {\n  return (\n    \u003Cdiv>\n      \u003Ch2>Something went wrong!\u003C\u002Fh2>\n      \u003Cbutton onClick={() => reset()}>Try again\u003C\u002Fbutton>\n    \u003C\u002Fdiv>\n  )\n}","code","tsx",[],{"id":189,"html":190,"type":137},"b12","\u003Cp>Nothing here is a syntax error, and \u003Ccode>reset\u003C\u002Fcode> 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&#39;s data fetch.\u003C\u002Fp>",{"id":192,"code":193,"type":185,"language":186,"highlight":194},"b13","\u002F\u002F app\u002Fdashboard\u002Fpage.tsx\nexport default async function DashboardPage() {\n  const res = await fetch('https:\u002F\u002Fapi.example.com\u002Fstats', { cache: 'no-store' })\n  if (!res.ok) throw new Error('Stats API is down')\n  const stats = await res.json()\n  return \u003CStats data={stats} \u002F>\n}",[],{"id":196,"html":197,"type":137},"b14","\u003Cp>Say \u003Ccode>\u002Fstats\u003C\u002Fcode> glitches for ten seconds and then recovers. A user who clicks a &quot;Try again&quot; button wired to \u003Ccode>reset()\u003C\u002Fcode> sees the same error, instantly. \u003Ccode>reset()\u003C\u002Fcode> clears the error boundary&#39;s internal state and re-renders its children — but &quot;re-render&quot; here means React re-rendering with whatever it already has on the client. Nothing gets re-fetched. The \u003Ccode>async\u003C\u002Fcode> 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.\u003C\u002Fp>",{"id":199,"html":200,"type":137},"b15","\u003Cp>That&#39;s precisely the gap \u003Ccode>retry()\u003C\u002Fcode> closes.\u003C\u002Fp>",{"id":202,"html":203,"text":203,"type":145,"level":31},"b16","The mental model: two recovery functions, two different operations",{"id":205,"html":206,"text":207,"type":145,"level":43},"b17","What an \u003Ccode>error.js\u003C\u002Fcode> boundary actually wraps","What an error.js boundary actually wraps",{"id":209,"html":210,"type":137},"b18","\u003Cp>An \u003Ccode>error.js\u003C\u002Fcode> file wraps a route segment and everything nested inside it in a React error boundary — but not everything at its own level:\u003C\u002Fp>",{"id":212,"code":213,"type":185,"language":214,"highlight":215},"b19","app\u002Fdashboard\u002F\n├─ layout.tsx         ← NOT wrapped by this segment's error.js\n├─ template.tsx        ← NOT wrapped either\n├─ error.tsx           ← the boundary starts here\n│    (wraps, within this segment and below:)\n│    ├─ loading.tsx\n│    ├─ not-found.tsx\n│    ├─ page.tsx\n│    └─ nested\u002Flayout.tsx   (and everything under it)","plain",[],{"id":217,"html":218,"type":137},"b20","\u003Cp>\u003Ccode>error.js\u003C\u002Fcode> wraps \u003Ccode>loading.js\u003C\u002Fcode>, \u003Ccode>not-found.js\u003C\u002Fcode>, \u003Ccode>page.js\u003C\u002Fcode>, and any nested \u003Ccode>layout.js\u003C\u002Fcode> below it — but it does \u003Cstrong>not\u003C\u002Fstrong> wrap the \u003Ccode>layout.js\u003C\u002Fcode> or \u003Ccode>template.js\u003C\u002Fcode> sitting beside it in the \u003Cem>same\u003C\u002Fem> segment. If the bug is in the layout itself, \u003Ccode>error.js\u003C\u002Fcode> never gets a chance to catch it; you need \u003Ccode>global-error.js\u003C\u002Fcode> instead (more on that below).\u003C\u002Fp>",{"id":220,"html":221,"text":222,"type":145,"level":43},"b21","\u003Ccode>retry()\u003C\u002Fcode> vs \u003Ccode>reset()\u003C\u002Fcode>, side by side","retry() vs reset(), side by side",{"id":224,"head":225,"rows":229,"type":246},"b22",[226,227,228],"","\u003Ccode>retry()\u003C\u002Fcode>","\u003Ccode>reset()\u003C\u002Fcode>",[230,234,238,242],[231,232,233],"Stabilized","\u003Ccode>v16.3.0\u003C\u002Fcode> (as \u003Ccode>unstable_retry\u003C\u002Fcode> in \u003Ccode>16.2.0\u003C\u002Fcode>)","Always available",[235,236,237],"What it does","Re-fetches and re-renders the error boundary&#39;s children","Clears the error state and re-renders without re-fetching",[239,240,241],"Recovers a Server Component data error","Yes — the Server Component actually runs again","No — nothing is re-fetched, so the same failure resurfaces",[243,244,245],"When to use it","The default choice for a &quot;Try again&quot; button","Only when you deliberately want to clear local error UI \u003Cem>without\u003C\u002Fem> a round trip","table",{"id":248,"html":249,"type":137},"b23","\u003Cp>The docs are direct about which one to reach for: &quot;In most cases, you should use \u003Ccode>retry()\u003C\u002Fcode> instead&quot; of \u003Ccode>reset()\u003C\u002Fcode>.\u003C\u002Fp>",{"id":251,"html":252,"text":252,"type":145,"level":43},"b24","What catches what",{"id":254,"html":255,"type":137},"b25","\u003Cp>Beyond the boundary itself, three more pieces round out the picture, and each is new or changed recently enough to be worth naming precisely:\u003C\u002Fp>",{"id":257,"type":151,"items":258,"ordered":18},"b26",[259,260,261],"\u003Cstrong>\u003Ccode>global-error.js\u003C\u002Fcode>\u003C\u002Fstrong> — handles errors in the root layout or template, which an ordinary \u003Ccode>error.js\u003C\u002Fcode> can never reach. It must define its own \u003Ccode>&lt;html&gt;\u003C\u002Fcode> and \u003Ccode>&lt;body&gt;\u003C\u002Fcode>, because it fully replaces the root layout when it activates. As of \u003Ccode>v15.2.0\u003C\u002Fcode> it also renders in development, not just production.","\u003Cstrong>\u003Ccode>global-not-found.js\u003C\u002Fcode>\u003C\u002Fstrong> \u003Cem>(experimental since \u003Ccode>v15.4.0\u003C\u002Fcode>)\u003C\u002Fem> — a routing-level 404 for URLs that match no route at all. Unlike \u003Ccode>not-found.js\u003C\u002Fcode>, which still renders inside your root layout, \u003Ccode>global-not-found.js\u003C\u002Fcode> skips rendering entirely and returns its own document. It&#39;s gated behind an \u003Ccode>experimental.globalNotFound\u003C\u002Fcode> flag in \u003Ccode>next.config.ts\u003C\u002Fcode> and, like \u003Ccode>global-error.js\u003C\u002Fcode>, needs its own \u003Ccode>&lt;html&gt;\u003C\u002Fcode>\u002F\u003Ccode>&lt;body&gt;\u003C\u002Fcode> and its own imported styles.","\u003Cstrong>\u003Ccode>catchError()\u003C\u002Fcode>\u003C\u002Fstrong> \u003Cem>(stable \u003Ccode>v16.3.0\u003C\u002Fcode>, as \u003Ccode>unstable_catchError\u003C\u002Fcode> in \u003Ccode>16.2.0\u003C\u002Fcode>)\u003C\u002Fem> — a function from \u003Ccode>next\u002Ferror\u003C\u002Fcode> that wraps any part of your component tree in an error boundary, not just a route segment. It&#39;s the one to reach for when you want recovery around a single widget without introducing a route-scoped \u003Ccode>error.tsx\u003C\u002Fcode>. Its own docs note a specific behavior: its \u003Ccode>retry()\u003C\u002Fcode> re-renders inside a React \u003Ca href=\"https:\u002F\u002Freact.dev\u002Freference\u002Freact\u002FstartTransition\">Transition\u003C\u002Fa>, which preserves the state of Client Components \u003Cem>outside\u003C\u002Fem> the boundary while it recovers.",{"id":263,"html":264,"text":264,"type":145,"level":31},"b27","Staged walkthrough",{"id":266,"html":267,"type":137},"b28","\u003Cp>\u003Cstrong>Step 1 — the request fails.\u003C\u002Fstrong> A request hits \u003Ccode>\u002Fdashboard\u003C\u002Fcode>. The Server Component&#39;s \u003Ccode>fetch\u003C\u002Fcode> to the stats API returns a non-OK response, and the component throws.\u003C\u002Fp>",{"id":269,"html":270,"type":137},"b29","\u003Cp>\u003Cstrong>Step 2 — the boundary catches it.\u003C\u002Fstrong> \u003Ccode>app\u002Fdashboard\u002Ferror.tsx\u003C\u002Fcode>, a Client Component, mounts and receives \u003Ccode>{ error, retry, reset }\u003C\u002Fcode> as props. In development, \u003Ccode>error.message\u003C\u002Fcode> carries the real thrown message. In production, Server Component errors are replaced with a generic message plus an \u003Ccode>error.digest\u003C\u002Fcode> — an automatically generated hash you can match against your server-side logs, specifically so the client never sees details it shouldn&#39;t.\u003C\u002Fp>",{"id":272,"html":273,"type":137},"b30","\u003Cp>\u003Cstrong>Step 3 — the user clicks \u003Ccode>retry()\u003C\u002Fcode>.\u003C\u002Fstrong> Next.js re-fetches and re-renders the error boundary&#39;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.\u003C\u002Fp>",{"id":275,"html":276,"type":137},"b31","\u003Cp>\u003Cstrong>Step 4 — compare: the user clicks \u003Ccode>reset()\u003C\u002Fcode> instead.\u003C\u002Fstrong> React clears the boundary&#39;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&#39;s either recaught immediately or the user is simply looking at stale output that doesn&#39;t reflect why the error went away — because, functionally, it didn&#39;t.\u003C\u002Fp>",{"id":278,"html":279,"type":137},"b32","\u003Cp>\u003Cstrong>Step 5 — the failure moves up a level.\u003C\u002Fstrong> Say the throw happens in the root layout itself, not a page. \u003Ccode>error.js\u003C\u002Fcode> never mounts for this one — a layout-level failure is exactly the case it&#39;s defined not to cover. You need \u003Ccode>app\u002Fglobal-error.tsx\u003C\u002Fcode>, with its own \u003Ccode>&lt;html&gt;\u003C\u002Fcode> and \u003Ccode>&lt;body&gt;\u003C\u002Fcode>, since it&#39;s replacing the entire root layout.\u003C\u002Fp>",{"id":281,"html":282,"type":137},"b33","\u003Cp>\u003Cstrong>Step 6 — the URL doesn&#39;t match anything at all.\u003C\u002Fstrong> This isn&#39;t a thrown error and it isn&#39;t a \u003Ccode>notFound()\u003C\u002Fcode> call either — nobody wrote a route for this path. The ordinary \u003Ccode>app\u002Fnot-found.tsx\u003C\u002Fcode> still handles this, rendered inside your root layout. But if your app has multiple root layouts (an \u003Ccode>(admin)\u003C\u002Fcode> and a \u003Ccode>(shop)\u003C\u002Fcode> route group, say) or a dynamic top-level segment like \u003Ccode>app\u002F[country]\u002Flayout.tsx\u003C\u002Fcode>, there may be no single layout to compose a consistent 404 from. That&#39;s what \u003Ccode>global-not-found.js\u003C\u002Fcode> is for — once you&#39;ve opted in with the \u003Ccode>globalNotFound\u003C\u002Fcode> experimental flag, it bypasses rendering and returns its own page for any unmatched URL, independent of which (if any) root layout would otherwise apply.\u003C\u002Fp>",{"id":284,"html":285,"type":137},"b34","\u003Cp>\u003Cstrong>Step 7 — recovery around one widget, not a whole route.\u003C\u002Fstrong> Say a single card on an otherwise-fine page can fail on its own and you don&#39;t want a route-wide \u003Ccode>error.tsx\u003C\u002Fcode> for it. \u003Ccode>catchError()\u003C\u002Fcode> wraps just that subtree:\u003C\u002Fp>",{"id":287,"code":288,"type":185,"language":186,"highlight":289},"b35","\u002F\u002F app\u002Fcustom-error-boundary.tsx\n'use client'\n\nimport { catchError, type ErrorInfo } from 'next\u002Ferror'\n\nfunction ErrorFallback(props: { title: string }, { error, retry }: ErrorInfo) {\n  const message = error instanceof Error ? error.message : String(error)\n  return (\n    \u003Cdiv>\n      \u003Ch2>{props.title}\u003C\u002Fh2>\n      \u003Cp>{message}\u003C\u002Fp>\n      \u003Cbutton onClick={() => retry()}>Try again\u003C\u002Fbutton>\n    \u003C\u002Fdiv>\n  )\n}\n\nexport default catchError(ErrorFallback)",[],{"id":291,"code":292,"type":185,"language":186,"highlight":293},"b36","\u002F\u002F app\u002Fdashboard\u002Fpage.tsx\nimport ErrorBoundary from '..\u002Fcustom-error-boundary'\n\nexport default function Page() {\n  return (\n    \u003CErrorBoundary title=\"Stats widget error\">\n      \u003CStatsWidget \u002F>\n    \u003C\u002FErrorBoundary>\n  )\n}",[],{"id":295,"html":296,"text":296,"type":145,"level":31},"b37","Edge cases",{"id":298,"type":151,"items":299,"ordered":18},"b38",[300,301,302,303,304,305],"\u003Cstrong>\u003Ccode>global-error.js\u003C\u002Fcode> only catches errors in the root layout itself\u003C\u002Fstrong> — it&#39;s the backstop above everything \u003Ccode>error.js\u003C\u002Fcode> can reach, not a catch-all for every error in the app. Before \u003Ccode>v15.2.0\u003C\u002Fcode> it only rendered in production; it now also shows in development.","\u003Cstrong>\u003Ccode>global-error.js\u003C\u002Fcode> and \u003Ccode>global-not-found.js\u003C\u002Fcode> don&#39;t inherit your app&#39;s styles or theme.\u003C\u002Fstrong> Both render their own document, bypassing your layout entirely, so an app-level theme toggle (a class or \u003Ccode>data-theme\u003C\u002Fcode> attribute) never reaches them. The default UI follows the OS color scheme; matching your app&#39;s explicit theme means applying it inside the file itself.","\u003Cstrong>Error boundaries don&#39;t catch errors in event handlers or async code that runs after rendering.\u003C\u002Fstrong> They&#39;re designed to catch errors \u003Cem>during\u003C\u002Fem> render. A \u003Ccode>throw\u003C\u002Fcode> inside an \u003Ccode>onClick\u003C\u002Fcode> handler needs a manual \u003Ccode>try\u003C\u002Fcode>\u002F\u003Ccode>catch\u003C\u002Fcode> plus \u003Ccode>useState\u003C\u002Fcode> to surface — \u003Ccode>error.js\u003C\u002Fcode> will never see it.","\u003Cstrong>An error thrown inside \u003Ccode>startTransition\u003C\u002Fcode> (from \u003Ccode>useTransition\u003C\u002Fcode>) does bubble up to the nearest error boundary\u003C\u002Fstrong>, even though it&#39;s technically running after the initial render.","\u003Cstrong>\u003Ccode>notFound()\u003C\u002Fcode> is special-cased — it never reaches \u003Ccode>error.js\u003C\u002Fcode>.\u003C\u002Fstrong> Calling it throws an internal signal that the router intercepts directly; it renders the nearest \u003Ccode>not-found.js\u003C\u002Fcode> up the tree, not your error boundary.","\u003Cstrong>\u003Ccode>global-not-found.js\u003C\u002Fcode> must return a complete document.\u003C\u002Fstrong> Because it bypasses your layout, it needs its own imported global styles, fonts, and \u003Ccode>&lt;html&gt;\u003C\u002Fcode>\u002F\u003Ccode>&lt;body&gt;\u003C\u002Fcode> tags — the same requirement as \u003Ccode>global-error.js\u003C\u002Fcode>, for the same reason.",{"id":307,"html":308,"text":308,"type":145,"level":31},"b39","Best practices",{"id":310,"type":151,"items":311,"ordered":18},"b40",[312,313,314,315,316,317],"\u003Cstrong>Wire &quot;Try again&quot; buttons to \u003Ccode>retry()\u003C\u002Fcode>, not \u003Ccode>reset()\u003C\u002Fcode>\u003C\u002Fstrong>, in every \u003Ccode>error.js\u003C\u002Fcode> 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.","\u003Cstrong>Reserve \u003Ccode>reset()\u003C\u002Fcode>\u003C\u002Fstrong> for the narrow case where you deliberately want to clear local error UI state without a round trip — nothing server-side needs re-checking.","\u003Cstrong>Give \u003Ccode>global-error.js\u003C\u002Fcode> (and \u003Ccode>global-not-found.js\u003C\u002Fcode>, if you adopt it) their own minimal, self-contained styling.\u003C\u002Fstrong> Neither inherits your app shell, so a bare, unstyled fallback is what ships if you forget.","\u003Cstrong>Reach for \u003Ccode>catchError()\u003C\u002Fcode>\u003C\u002Fstrong> when you want a boundary around a component, not a route — it saves you from inventing a route-scoped \u003Ccode>error.tsx\u003C\u002Fcode> just to wrap one widget.","\u003Cstrong>Treat \u003Ccode>global-not-found.js\u003C\u002Fcode> as experimental until it stabilizes.\u003C\u002Fstrong> Only reach for it if you genuinely have multiple root layouts or a dynamic root segment that makes a normal \u003Ccode>layout.js\u003C\u002Fcode> + \u003Ccode>not-found.js\u003C\u002Fcode> 404 impossible to compose.","\u003Cstrong>Log \u003Ccode>error.digest\u003C\u002Fcode> server-side.\u003C\u002Fstrong> It&#39;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.",{"id":319,"html":320,"text":320,"type":145,"level":31},"b41","FAQ",{"id":322,"html":323,"text":324,"type":145,"level":43},"b42","Is \u003Ccode>retry()\u003C\u002Fcode> a drop-in replacement for \u003Ccode>reset()\u003C\u002Fcode>?","Is retry() a drop-in replacement for reset()?",{"id":326,"html":327,"type":137},"b43","\u003Cp>No. They&#39;re both still valid props on \u003Ccode>error.js\u003C\u002Fcode>, but they do different things: \u003Ccode>retry()\u003C\u002Fcode> re-fetches and re-renders, \u003Ccode>reset()\u003C\u002Fcode> only clears state and re-renders. Swapping the name without checking the behavior you actually need would be the wrong kind of &quot;fix.&quot;\u003C\u002Fp>",{"id":329,"html":330,"text":331,"type":145,"level":43},"b44","Will my existing \u003Ccode>error.js\u003C\u002Fcode> files break if I leave them using \u003Ccode>reset()\u003C\u002Fcode>?","Will my existing error.js files break if I leave them using reset()?",{"id":333,"html":334,"type":137},"b45","\u003Cp>No — \u003Ccode>reset()\u003C\u002Fcode> is still exported and still works exactly as it always has. It just won&#39;t recover from a Server Component data error, which is the most common reason an error boundary fires in the first place.\u003C\u002Fp>",{"id":336,"html":337,"text":338,"type":145,"level":43},"b46","Does \u003Ccode>error.js\u003C\u002Fcode> catch errors thrown in my root layout?","Does error.js catch errors thrown in my root layout?",{"id":340,"html":341,"type":137},"b47","\u003Cp>No. \u003Ccode>error.js\u003C\u002Fcode> wraps the segment below it, not the \u003Ccode>layout.js\u003C\u002Fcode> or \u003Ccode>template.js\u003C\u002Fcode> sitting beside it at the same level. A root layout failure needs \u003Ccode>global-error.js\u003C\u002Fcode>.\u003C\u002Fp>",{"id":343,"html":344,"text":345,"type":145,"level":43},"b48","Why doesn&#39;t calling \u003Ccode>notFound()\u003C\u002Fcode> trigger my \u003Ccode>error.js\u003C\u002Fcode>?","Why doesn't calling notFound() trigger my error.js?",{"id":347,"html":348,"type":137},"b49","\u003Cp>Because it isn&#39;t treated as a normal thrown error. \u003Ccode>notFound()\u003C\u002Fcode> throws an internal signal the router intercepts directly, rendering the nearest \u003Ccode>not-found.js\u003C\u002Fcode> instead of handing anything to your error boundary.\u003C\u002Fp>",{"id":350,"html":351,"text":352,"type":145,"level":43},"b50","What&#39;s the actual difference between \u003Ccode>not-found.js\u003C\u002Fcode> and \u003Ccode>global-not-found.js\u003C\u002Fcode>?","What's the actual difference between not-found.js and global-not-found.js?",{"id":354,"html":355,"type":137},"b51","\u003Cp>\u003Ccode>not-found.js\u003C\u002Fcode> renders for \u003Ccode>notFound()\u003C\u002Fcode> calls and for unmatched URLs, and it still renders inside your root layout. \u003Ccode>global-not-found.js\u003C\u002Fcode> (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&#39;t compose one consistent 404 page any other way.\u003C\u002Fp>",{"id":357,"html":358,"text":359,"type":145,"level":43},"b52","When should I reach for \u003Ccode>catchError()\u003C\u002Fcode> instead of an \u003Ccode>error.tsx\u003C\u002Fcode> file?","When should I reach for catchError() instead of an error.tsx file?",{"id":361,"html":362,"type":137},"b53","\u003Cp>When the thing that needs recovery is a component, not a route segment — a single widget or card, somewhere inside a page that&#39;s otherwise fine.\u003C\u002Fp>",{"id":364,"html":365,"text":365,"type":145,"level":43},"b54","Does any of this apply to the Pages Router?",{"id":367,"html":368,"type":137},"b55","\u003Cp>Only partly. \u003Ccode>error.js\u003C\u002Fcode>, \u003Ccode>global-error.js\u003C\u002Fcode>, and \u003Ccode>global-not-found.js\u003C\u002Fcode> are App Router conventions with no Pages Router equivalent. \u003Ccode>catchError()\u003C\u002Fcode> does have a Pages Router form, but it only exposes \u003Ccode>reset()\u003C\u002Fcode> there — \u003Ccode>retry()\u003C\u002Fcode> is an App Router–only capability, because it depends on re-rendering Server Components.\u003C\u002Fp>",{"id":370,"html":371,"text":371,"type":145,"level":31},"b56","Cheat sheet",{"id":373,"code":374,"type":185,"language":214,"highlight":375},"b57","Next.js error & not-found conventions — what catches what, and with what:\n\nerror.js (Client Component, wraps a route segment)\n  Wraps:     loading.js, not-found.js, page.js, nested layout.js (and below)\n  Does NOT wrap: layout.js \u002F template.js at its OWN segment level\n  Props:     error, retry, reset\n    retry()  → re-fetches + re-renders children (stable v16.3.0, was unstable_retry in v16.2.0)\n    reset()  → clears error state only, re-renders WITHOUT re-fetching\n  Use retry() by default. reset() only when nothing needs a round trip.\n\nglobal-error.js (root app\u002F directory)\n  Catches errors in the ROOT layout\u002Ftemplate only — error.js can't reach these\n  Must define its own \u003Chtml> and \u003Cbody>\n  Renders in dev too, since v15.2.0 (was production-only before)\n  Does not inherit your app's global styles or theme\n\nnot-found.js vs global-not-found.js (experimental, v15.4.0+)\n  not-found.js        → notFound() calls + unmatched URLs; renders INSIDE root layout\n  global-not-found.js → unmatched URLs only; BYPASSES layouts, own \u003Chtml>\u002F\u003Cbody>\n                         needs `experimental.globalNotFound: true` in next.config.ts\n                         for: multiple root layouts, or a dynamic root segment\n\ncatchError() (from 'next\u002Ferror', stable v16.3.0, was unstable_catchError in v16.2.0)\n  Wraps ANY component subtree, not just a route segment\n  App Router: { error, retry, reset } — retry() runs inside a Transition,\n    preserving Client Component state OUTSIDE the boundary\n  Pages Router: { error, reset } only — no retry()\n\nnotFound() is special-cased: it never reaches error.js, the router renders\nnot-found.js directly.\n\nErrors in event handlers \u002F post-render async code are NOT caught by any of\nthese — catch them manually with try\u002Fcatch + useState.",[],{"id":377,"html":378,"type":137},"b58","\u003C!-- playground:start -->",{"id":380,"html":381,"text":381,"type":145,"level":31},"b59","🎮 Try it yourself",{"id":383,"html":384,"type":137},"b60","\u003Cp>\u003Cstrong>\u003Ca href=\"https:\u002F\u002Fbestpractic.org\u002Fblog\u002Fnextjs-weekly-error-retry-vs-reset\u002Fplayground\">▶️ Open the interactive playground →\u003C\u002Fa>\u003C\u002Fstrong>\u003C\u002Fp>",{"id":386,"html":387,"type":137},"b61","\u003Cp>\u003Cem>Runs right in your browser — poke at it and watch the concept react live.\u003C\u002Fem>\u003C\u002Fp>",{"id":389,"html":390,"type":137},"b62","\u003C!-- playground:end -->",{"id":392,"html":393,"text":393,"type":145,"level":31},"b63","Key takeaways",{"id":395,"type":151,"items":396,"ordered":18},"b64",[397,398,399],"\u003Ccode>retry()\u003C\u002Fcode> (stable since \u003Ccode>v16.3.0\u003C\u002Fcode>) re-fetches and re-renders an error boundary&#39;s children; \u003Ccode>reset()\u003C\u002Fcode> only clears local error state. They are not interchangeable, and most &quot;Try again&quot; buttons should be calling \u003Ccode>retry()\u003C\u002Fcode>.","An \u003Ccode>error.js\u003C\u002Fcode> boundary wraps everything below it in its segment, but never the \u003Ccode>layout.js\u003C\u002Fcode>\u002F\u003Ccode>template.js\u003C\u002Fcode> sitting beside it — that gap belongs to \u003Ccode>global-error.js\u003C\u002Fcode>.","\u003Ccode>global-not-found.js\u003C\u002Fcode> (experimental since \u003Ccode>v15.4.0\u003C\u002Fcode>) and \u003Ccode>catchError()\u003C\u002Fcode> (stable since \u003Ccode>v16.3.0\u003C\u002Fcode>) round out the toolbox for the cases a route-scoped \u003Ccode>error.js\u003C\u002Fcode> was never going to reach.",{"id":401,"html":402,"type":137},"b65","\u003Cp>If your \u003Ccode>error.js\u003C\u002Fcode> files have been quietly shipping \u003Ccode>reset()\u003C\u002Fcode> since before any of this existed, you&#39;re not alone, and nothing is currently broken in a way that throws a warning. But the next time a Server Component&#39;s data dependency hiccups for a few seconds, the difference between those two function calls is the difference between a &quot;Try again&quot; button that actually works and one that just plays dead and comes back.\u003C\u002Fp>",{"id":404,"html":405,"type":137},"b66","\u003C!-- quiz:start -->",{"id":407,"html":408,"text":408,"type":145,"level":31},"b67","🧠 Test yourself",{"id":410,"html":411,"type":137},"b68","\u003Cp>Think it clicked? \u003Cstrong>\u003Ca href=\"https:\u002F\u002Fbestpractic.org\u002Fblog\u002Fnextjs-weekly-error-retry-vs-reset\u002Fquiz\">Take the 8-question quiz →\u003C\u002Fa>\u003C\u002Fstrong>\u003C\u002Fp>",{"id":413,"html":414,"type":137},"b69","\u003Cp>\u003Cem>Instant feedback, a hint on every question, and an explanation for each answer — right or wrong.\u003C\u002Fem>\u003C\u002Fp>",{"id":416,"html":417,"type":137},"b70","\u003C!-- quiz:end -->",{"id":419,"html":420,"type":137},"b71","\u003C!-- related:start -->",{"id":422,"html":423,"text":423,"type":145,"level":31},"b72","📚 Read next",{"id":425,"type":151,"items":426,"ordered":18},"b73",[427,428,429],"\u003Ca href=\"https:\u002F\u002Fbestpractic.org\u002Fblog\u002Fnextjs-weekly-cache-components-explained\">Next.js Cache Components Explained (with Cheat Sheet)\u003C\u002Fa>","\u003Ca href=\"https:\u002F\u002Fbestpractic.org\u002Fblog\u002Fnextjs-weekly-image-priority-quality-changes\">Next.js 16 Image: priority Deprecated, quality Now Allowlisted\u003C\u002Fa>","\u003Ca href=\"https:\u002F\u002Fbestpractic.org\u002Fblog\u002Fnextjs-weekly-server-actions-mutations-security\">Next.js Server Actions: Mutations &amp; Security (Cheat Sheet)\u003C\u002Fa>",{"id":431,"html":432,"type":137},"b74","\u003C!-- related:end -->",{"id":434,"type":435},"b75","divider",{"id":437,"html":438,"type":137},"b76","\u003Cp>🚀 \u003Cstrong>Want more like this?\u003C\u002Fstrong> Every guide, playground, and quiz lives on \u003Cstrong>\u003Ca href=\"https:\u002F\u002Fbestpractic.org\u002F\">bestpractic.org\u003C\u002Fa>\u003C\u002Fstrong> — open it and \u003Cstrong>\u003Ca href=\"https:\u002F\u002Fbestpractic.org\u002F\">sign up free\u003C\u002Fa>\u003C\u002Fstrong> so the next one finds you.\u003C\u002Fp>",{"id":440,"html":441,"type":137},"b77","\u003Cp>\u003Cem>Thanks for reading! Let&#39;s stay connected:\u003C\u002Fem>\u003C\u002Fp>",{"id":443,"type":151,"items":444,"ordered":18},"b78",[445,446,447],"⭐ \u003Cstrong>GitHub\u003C\u002Fstrong> — follow me and star the projects: \u003Ca href=\"https:\u002F\u002Fgithub.com\u002Fparsajiravand\">github.com\u002Fparsajiravand\u003C\u002Fa>","💬 \u003Cstrong>Discord\u003C\u002Fstrong> — join the frontend best-practices community: \u003Ca href=\"https:\u002F\u002Fdiscord.gg\u002Fd9KRhuAwQ\">discord.gg\u002Fd9KRhuAwQ\u003C\u002Fa>","📸 \u003Cstrong>Instagram\u003C\u002Fstrong> — frontend best practices, daily: \u003Ca href=\"https:\u002F\u002Fwww.instagram.com\u002Fbestpractice___\u002F\">@bestpractice___\u003C\u002Fa>","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.\n\nThis 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()` \u002F `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.\n\n## What you'll learn\n\nBy the end of this article you'll be able to:\n\n- Explain exactly what `retry()` does differently from `reset()`, and why only one of them can recover a failed Server Component\n- 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\n- Know when you need `global-error.js` instead, and what it costs you (no inherited styles, its own `\u003Chtml>`\u002F`\u003Cbody>`)\n- Tell `not-found.js` apart from the new, still-experimental `global-not-found.js`, and know which one you actually need\n- Use `catchError()` to put an error boundary around a single component without creating a route-scoped `error.tsx` file\n\n**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](https:\u002F\u002Fdev.to\u002Fparsajiravand\u002Fnextjs-server-actions-mutations-security-cheat-sheet-b63) episode covers that boundary from the mutation side — worth reading first, not required.\n\n## Contents\n\n- [The wrong way: wiring \"Try again\" to reset()](#the-wrong-way-wiring-try-again-to-reset)\n- [The mental model: two recovery functions, two different operations](#the-mental-model-two-recovery-functions-two-different-operations)\n- [Staged walkthrough](#staged-walkthrough)\n- [Edge cases](#edge-cases)\n- [Best practices](#best-practices)\n- [FAQ](#faq)\n- [Cheat sheet](#cheat-sheet)\n- [Key takeaways](#key-takeaways)\n\n## The wrong way: wiring \"Try again\" to reset()\n\nThis 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:\n\n```tsx\n\u002F\u002F app\u002Fdashboard\u002Ferror.tsx — looks right, recovers nothing\n'use client' \u002F\u002F Error boundaries must be Client Components\n\nexport default function Error({\n  error,\n  reset,\n}: {\n  error: unknown\n  reset: () => void\n}) {\n  return (\n    \u003Cdiv>\n      \u003Ch2>Something went wrong!\u003C\u002Fh2>\n      \u003Cbutton onClick={() => reset()}>Try again\u003C\u002Fbutton>\n    \u003C\u002Fdiv>\n  )\n}\n```\n\nNothing 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.\n\n```tsx\n\u002F\u002F app\u002Fdashboard\u002Fpage.tsx\nexport default async function DashboardPage() {\n  const res = await fetch('https:\u002F\u002Fapi.example.com\u002Fstats', { cache: 'no-store' })\n  if (!res.ok) throw new Error('Stats API is down')\n  const stats = await res.json()\n  return \u003CStats data={stats} \u002F>\n}\n```\n\nSay `\u002Fstats` 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.\n\nThat's precisely the gap `retry()` closes.\n\n## The mental model: two recovery functions, two different operations\n\n### What an `error.js` boundary actually wraps\n\nAn `error.js` file wraps a route segment and everything nested inside it in a React error boundary — but not everything at its own level:\n\n```\napp\u002Fdashboard\u002F\n├─ layout.tsx         ← NOT wrapped by this segment's error.js\n├─ template.tsx        ← NOT wrapped either\n├─ error.tsx           ← the boundary starts here\n│    (wraps, within this segment and below:)\n│    ├─ loading.tsx\n│    ├─ not-found.tsx\n│    ├─ page.tsx\n│    └─ nested\u002Flayout.tsx   (and everything under it)\n```\n\n`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).\n\n### `retry()` vs `reset()`, side by side\n\n| | `retry()` | `reset()` |\n|---|---|---|\n| Stabilized | `v16.3.0` (as `unstable_retry` in `16.2.0`) | Always available |\n| What it does | Re-fetches and re-renders the error boundary's children | Clears the error state and re-renders without re-fetching |\n| Recovers a Server Component data error | Yes — the Server Component actually runs again | No — nothing is re-fetched, so the same failure resurfaces |\n| 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 |\n\nThe docs are direct about which one to reach for: \"In most cases, you should use `retry()` instead\" of `reset()`.\n\n### What catches what\n\nBeyond the boundary itself, three more pieces round out the picture, and each is new or changed recently enough to be worth naming precisely:\n\n- **`global-error.js`** — handles errors in the root layout or template, which an ordinary `error.js` can never reach. It must define its own `\u003Chtml>` and `\u003Cbody>`, because it fully replaces the root layout when it activates. As of `v15.2.0` it also renders in development, not just production.\n- **`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 `\u003Chtml>`\u002F`\u003Cbody>` and its own imported styles.\n- **`catchError()`** *(stable `v16.3.0`, as `unstable_catchError` in `16.2.0`)* — a function from `next\u002Ferror` 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](https:\u002F\u002Freact.dev\u002Freference\u002Freact\u002FstartTransition), which preserves the state of Client Components *outside* the boundary while it recovers.\n\n## Staged walkthrough\n\n**Step 1 — the request fails.** A request hits `\u002Fdashboard`. The Server Component's `fetch` to the stats API returns a non-OK response, and the component throws.\n\n**Step 2 — the boundary catches it.** `app\u002Fdashboard\u002Ferror.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.\n\n**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.\n\n**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.\n\n**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\u002Fglobal-error.tsx`, with its own `\u003Chtml>` and `\u003Cbody>`, since it's replacing the entire root layout.\n\n**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\u002Fnot-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\u002F[country]\u002Flayout.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.\n\n**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:\n\n```tsx\n\u002F\u002F app\u002Fcustom-error-boundary.tsx\n'use client'\n\nimport { catchError, type ErrorInfo } from 'next\u002Ferror'\n\nfunction ErrorFallback(props: { title: string }, { error, retry }: ErrorInfo) {\n  const message = error instanceof Error ? error.message : String(error)\n  return (\n    \u003Cdiv>\n      \u003Ch2>{props.title}\u003C\u002Fh2>\n      \u003Cp>{message}\u003C\u002Fp>\n      \u003Cbutton onClick={() => retry()}>Try again\u003C\u002Fbutton>\n    \u003C\u002Fdiv>\n  )\n}\n\nexport default catchError(ErrorFallback)\n```\n\n```tsx\n\u002F\u002F app\u002Fdashboard\u002Fpage.tsx\nimport ErrorBoundary from '..\u002Fcustom-error-boundary'\n\nexport default function Page() {\n  return (\n    \u003CErrorBoundary title=\"Stats widget error\">\n      \u003CStatsWidget \u002F>\n    \u003C\u002FErrorBoundary>\n  )\n}\n```\n\n## Edge cases\n\n- **`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.\n- **`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.\n- **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`\u002F`catch` plus `useState` to surface — `error.js` will never see it.\n- **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.\n- **`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.\n- **`global-not-found.js` must return a complete document.** Because it bypasses your layout, it needs its own imported global styles, fonts, and `\u003Chtml>`\u002F`\u003Cbody>` tags — the same requirement as `global-error.js`, for the same reason.\n\n## Best practices\n\n- **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.\n- **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.\n- **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.\n- **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.\n- **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.\n- **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.\n\n## FAQ\n\n### Is `retry()` a drop-in replacement for `reset()`?\n\nNo. 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.\"\n\n### Will my existing `error.js` files break if I leave them using `reset()`?\n\nNo — `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.\n\n### Does `error.js` catch errors thrown in my root layout?\n\nNo. `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`.\n\n### Why doesn't calling `notFound()` trigger my `error.js`?\n\nBecause 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.\n\n### What's the actual difference between `not-found.js` and `global-not-found.js`?\n\n`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.\n\n### When should I reach for `catchError()` instead of an `error.tsx` file?\n\nWhen 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.\n\n### Does any of this apply to the Pages Router?\n\nOnly 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.\n\n## Cheat sheet\n\n```\nNext.js error & not-found conventions — what catches what, and with what:\n\nerror.js (Client Component, wraps a route segment)\n  Wraps:     loading.js, not-found.js, page.js, nested layout.js (and below)\n  Does NOT wrap: layout.js \u002F template.js at its OWN segment level\n  Props:     error, retry, reset\n    retry()  → re-fetches + re-renders children (stable v16.3.0, was unstable_retry in v16.2.0)\n    reset()  → clears error state only, re-renders WITHOUT re-fetching\n  Use retry() by default. reset() only when nothing needs a round trip.\n\nglobal-error.js (root app\u002F directory)\n  Catches errors in the ROOT layout\u002Ftemplate only — error.js can't reach these\n  Must define its own \u003Chtml> and \u003Cbody>\n  Renders in dev too, since v15.2.0 (was production-only before)\n  Does not inherit your app's global styles or theme\n\nnot-found.js vs global-not-found.js (experimental, v15.4.0+)\n  not-found.js        → notFound() calls + unmatched URLs; renders INSIDE root layout\n  global-not-found.js → unmatched URLs only; BYPASSES layouts, own \u003Chtml>\u002F\u003Cbody>\n                         needs `experimental.globalNotFound: true` in next.config.ts\n                         for: multiple root layouts, or a dynamic root segment\n\ncatchError() (from 'next\u002Ferror', stable v16.3.0, was unstable_catchError in v16.2.0)\n  Wraps ANY component subtree, not just a route segment\n  App Router: { error, retry, reset } — retry() runs inside a Transition,\n    preserving Client Component state OUTSIDE the boundary\n  Pages Router: { error, reset } only — no retry()\n\nnotFound() is special-cased: it never reaches error.js, the router renders\nnot-found.js directly.\n\nErrors in event handlers \u002F post-render async code are NOT caught by any of\nthese — catch them manually with try\u002Fcatch + useState.\n```\n\n\u003C!-- playground:start -->\n\n## 🎮 Try it yourself\n\n**[▶️ Open the interactive playground →](https:\u002F\u002Fbestpractic.org\u002Fblog\u002Fnextjs-weekly-error-retry-vs-reset\u002Fplayground)**\n\n_Runs right in your browser — poke at it and watch the concept react live._\n\n\u003C!-- playground:end -->\n\n## Key takeaways\n\n- `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()`.\n- An `error.js` boundary wraps everything below it in its segment, but never the `layout.js`\u002F`template.js` sitting beside it — that gap belongs to `global-error.js`.\n- `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.\n\nIf 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.\n\n\u003C!-- quiz:start -->\n\n## 🧠 Test yourself\n\nThink it clicked? **[Take the 8-question quiz →](https:\u002F\u002Fbestpractic.org\u002Fblog\u002Fnextjs-weekly-error-retry-vs-reset\u002Fquiz)**\n\n_Instant feedback, a hint on every question, and an explanation for each answer — right or wrong._\n\n\u003C!-- quiz:end -->\n\n\u003C!-- related:start -->\n\n## 📚 Read next\n\n- [Next.js Cache Components Explained (with Cheat Sheet)](https:\u002F\u002Fbestpractic.org\u002Fblog\u002Fnextjs-weekly-cache-components-explained)\n- [Next.js 16 Image: priority Deprecated, quality Now Allowlisted](https:\u002F\u002Fbestpractic.org\u002Fblog\u002Fnextjs-weekly-image-priority-quality-changes)\n- [Next.js Server Actions: Mutations & Security (Cheat Sheet)](https:\u002F\u002Fbestpractic.org\u002Fblog\u002Fnextjs-weekly-server-actions-mutations-security)\n\n\u003C!-- related:end -->\n\n---\n\n🚀 **Want more like this?** Every guide, playground, and quiz lives on **[bestpractic.org](https:\u002F\u002Fbestpractic.org\u002F)** — open it and **[sign up free](https:\u002F\u002Fbestpractic.org\u002F)** so the next one finds you.\n\n*Thanks for reading! Let's stay connected:*\n\n- ⭐ **GitHub** — follow me and star the projects: [github.com\u002Fparsajiravand](https:\u002F\u002Fgithub.com\u002Fparsajiravand)\n- 💬 **Discord** — join the frontend best-practices community: [discord.gg\u002Fd9KRhuAwQ](https:\u002F\u002Fdiscord.gg\u002Fd9KRhuAwQ)\n- 📸 **Instagram** — frontend best practices, daily: [@bestpractice___](https:\u002F\u002Fwww.instagram.com\u002Fbestpractice___\u002F)",{"title":111,"canonical":450,"description":112},"https:\u002F\u002Fbestpractic.org\u002Fblog\u002Fnextjs-weekly-error-retry-vs-reset","01a1df1b-203c-7390-aa4a-4154be665a96",{"name":453,"part":454,"total":108,"items":455},"Next.js Deep Dive",12,[456,461,466,470,474,478,482,486,490,494,498,502,503],{"slug":457,"title":458,"publishedAt":459,"readingMinutes":460},"nextjs-weekly-cache-components-explained","Next.js Cache Components Explained (with Cheat Sheet)","2026-09-01T11:24:15.087Z",14,{"slug":462,"title":463,"publishedAt":464,"readingMinutes":465},"nextjs-weekly-server-actions-mutations-security","Next.js Server Actions: Mutations & Security (Cheat Sheet)","2026-09-08T10:57:00.975Z",15,{"slug":467,"title":468,"publishedAt":469,"readingMinutes":460},"nextjs-weekly-parallel-intercepting-routes-modals","Next.js Parallel & Intercepting Routes: Modals Done Right","2026-09-15T17:50:47.218Z",{"slug":471,"title":472,"publishedAt":473,"readingMinutes":454},"nextjs-weekly-middleware-to-proxy-network-boundary","Next.js proxy.ts Explained (with Cheat Sheet)","2026-09-22T19:36:08.416Z",{"slug":475,"title":476,"publishedAt":477,"readingMinutes":465},"nextjs-weekly-route-handlers-caching-streaming","Next.js Route Handlers: GET Stopped Caching in 15 — How to Cache in 16","2026-09-29T09:16:08.176Z",{"slug":479,"title":480,"publishedAt":481,"readingMinutes":460},"nextjs-weekly-streaming-metadata-head","Next.js Streaming Metadata: Why Your `\u003Chead>` Looks Incomplete","2026-10-06T06:10:31.468Z",{"slug":483,"title":484,"publishedAt":485,"readingMinutes":465},"nextjs-weekly-image-priority-quality-changes","Next.js 16 Image: priority Deprecated, quality Now Allowlisted","2026-10-13T06:10:29.815Z",{"slug":487,"title":488,"publishedAt":489,"readingMinutes":460},"nextjs-weekly-instant-navigations-partial-prefetching","Next.js 16.3 Instant Navigations: How Partial Prefetching Works","2026-10-20T06:10:59.936Z",{"slug":491,"title":492,"publishedAt":493,"readingMinutes":460},"nextjs-weekly-updatetag-vs-revalidatetag","Next.js 16 updateTag vs revalidateTag: What Changed","2026-10-27T06:11:02.727Z",{"slug":495,"title":496,"publishedAt":497,"readingMinutes":108},"nextjs-weekly-ensurestatic-locks-static-output","Next.js 16.4 ensureStatic: Locking Routes Fully Static","2026-11-03T06:10:26.449Z",{"slug":499,"title":500,"publishedAt":501,"readingMinutes":108},"nextjs-weekly-unstable-cache-root-params-leak","Next.js 16.4.5: How unstable_cache Leaked Data Across Root Params","2026-11-10T20:39:47.146Z",{"slug":46,"title":111,"publishedAt":114,"readingMinutes":108},{"slug":504,"title":505,"publishedAt":506,"readingMinutes":507},"nextjs-weekly-use-cache-remote-vs-private","Next.js 16 use cache: remote vs use cache: private","2026-11-27T11:47:29.944Z",16,{"id":509,"locked":18},"01a1df1b-2066-724d-ab26-5974f4f17693",[511],{"id":45,"slug":46,"title":48,"_count":512},{"questions":51},[514],{"locale":13,"slug":46},{"id":45,"slug":46,"title":48,"_count":516,"questionCount":51},{"questions":51},[]]