- All Courses
- Next.js for Production
- Shipping to Production
- Error boundaries and instrumentation
Error boundaries and instrumentation
An error file wraps its segment in a boundary, so a crash in one panel leaves the rest of the page usable and offers a retry.
Overview
Failing in one place instead of everywhere
An error file wraps its segment in a boundary, so a crash in one panel leaves the rest of the page usable and offers a retry. Without it, a single thrown error replaces the whole application with a blank screen.
Boundaries are per segment, which means placement is a design decision. A boundary at the root is a safety net; a boundary around each widget is a resilient dashboard.
Expected failures are not errors. A record that does not exist should call notFound(), not throw — mixing the two floods your error reporting with 404s and buries the real bugs.
In this lesson you will:
- Contain a render error to one segment
- Report errors somewhere you will actually see them
- Distinguish expected failures from bugs
Resources
Notes are not saved yet — they clear when you leave this page.
Optimistic updates with useOptimistic
9m
Image and font optimization
9m