Skip to main content

Dec 2026 · Guide · ~7 min read

React Error Boundaries — What They Catch and What They Don't

By Safdar Ali — frontend engineer, Bengaluru

I'm Safdar Ali. An error boundary is a component that catches a JavaScript error in its child tree during render and shows a fallback instead of unmounting the whole app. In the App Router, error.js is that boundary for a route segment.

It does not catch errors inside event handlers, async code, or the server's own logging. A click handler needs its own try/catch and a message in the UI. People wrap the page in a boundary and then wonder why the button failure still vanished into the console.

Put the boundary where a failure should be contained. A broken widget should not take down the article. A broken article can take down the article route and leave the nav, which lives in a parent layout that did not error.

The fallback needs a way forward: retry, or a link home. A sentence that says "something went wrong" with no action is a dead end. Log the error on the server or your error reporter so you hear about it before the user emails you.

Do not catch errors by rendering null. That hides the bug and leaves a hole. Show the fallback and fix the throw.

If this helped you

I publish free tutorials and write-ups like this in my spare time — no paywall on the guides. If it saved you an afternoon of trial and error, you can support the work:

More guides on safdarali.in — same author, production-focused.

"Talk is cheap. Show me the code."