Catch render errors with a React error boundary or Next.js error handling
Answer: A render error can cause React to remove its UI from the screen. You can display fallback UI for the part that crashed by wrapping it in an Error Boundary. Next.js divides errors into expected errors and uncaught exceptions.
What an Error Boundary catches
An Error Boundary wraps part of the UI and can show fallback UI, for example an error message. Error boundaries do not catch errors for event handlers, server side rendering, errors thrown in the error boundary itself, or asynchronous code such as setTimeout. Class components still provide this with getDerivedStateFromError and componentDidCatch.
Expected errors in Next.js
Expected errors can occur during normal operation, including failed requests. They should be returned to the client. For Server Functions, the Next.js page shows useActionState to handle those expected errors. Avoid try/catch and thrown errors for that case; model expected errors as return values.
| Error Boundary | Next.js | |---|---| | fallback UI | Displayed instead of the part that crashed | | event handlers | Not caught by an Error Boundary | | expected errors | Handled explicitly and returned to the client | | useActionState | Hook shown for expected errors in Server Functions |
See also
Claims
- id: C1 claim: An Error Boundary can display fallback UI instead of the part of the tree that crashed. source: S1 evidence: "display some fallback UI instead of the part that crashed"
- id: C2 claim: Error boundaries do not catch errors in event handlers or several other cases. source: S1 evidence: "Error boundaries do not catch errors for"
- id: C3 claim: Next.js divides errors into expected errors and uncaught exceptions. source: S2 evidence: "expected errors and uncaught exceptions"
Sources
- [S1] Component. React docs. https://react.dev/reference/react/Component#catching-rendering-errors-with-an-error-boundary . License: CC-BY-4.0. Accessed 2026-11-19.
- [S2] Error Handling. Next.js docs. https://nextjs.org/docs/app/getting-started/error-handling . License: MIT. Accessed 2026-11-19.
License: this note is CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). Summary by iinventedlight (AI-assisted). Sources: React docs, Component; Next.js docs, Error Handling. CC-BY-4.0; MIT. Text was condensed and changed from the originals.
License: CC-BY-4.0 · Summary by iinventedlight (AI-assisted). Sources: React docs, Component; Next.js docs, Error Handling. CC-BY-4.0; MIT.
Cite this
iinventedlight. 2026. "Catch render errors with a React error boundary or Next.js error handling." iinventedlight Library, iil:note:ad49qwpw, version of 2026-11-19. https://iinventedlight.com/library/notes/react-error-boundaries/. License: CC-BY-4.0.
@misc{iil_note_ad49qwpw,
author = {{iinventedlight}},
title = {{Catch render errors with a React error boundary or Next.js error handling}},
howpublished = {iinventedlight Library},
year = {2026},
date = {2026-11-19},
url = {https://iinventedlight.com/library/notes/react-error-boundaries/},
note = {Permanent ID iil:note:ad49qwpw. License: CC-BY-4.0.},
}
Spotted a mistake? Use the MCP feedback tool or email hello@iinventedlight.com. Or Report a correction (no account needed).
Extra files beside this note
These files use this note's license, shown below. Paper extras retain their reproduction status; a link is not a reproduction.
- react-error-boundaries.table.json (table; CC-BY-4.0)
- react-error-boundaries.schema.json (schema; CC-BY-4.0)
For language models and agents: start at /llms.txt | /agents.md | /.well-known/agent-library.json. This page in Markdown: /library/notes/react-error-boundaries.md.