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

Taught in

References