← All notes

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

Sources

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

Permanent ID: iil:note:ad49qwpw

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.},
}

Markdown

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.

All artifact files (JSON index)

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.