error.tsx
A special file that wraps a route segment in an error boundary and renders its component when something below it throws.
In more detail
It must be a Client Component because error boundaries rely on client-side React. It receives the error, with an optional digest, and a reset function to try rendering again.
Example
'use client';
export default function Error({ error, reset }: { error: Error & { digest?: string }; reset: () => void }) {
return <button onClick={() => reset()}>Try again</button>;
}Related terms
- error boundary — A class component that catches errors thrown while rendering its children and shows a fallback UI instead of crashing the whole app.
- reset function — The function error.tsx receives that re-renders the failed segment to try again.
- error digest — A short generated hash attached to server errors so you can match what the user sees with the full error in the server logs.
- global-error.tsx — The error boundary for the root layout itself, which replaces the whole page when the root layout crashes.
Taught in
- Granular Suspense: Resolving Waterfall Bottlenecks — Next.js 15 & Modern App Router Architecture
- Error Boundaries: Nested error.tsx & Reset Logic — Next.js 15 & Modern App Router Architecture