File conventions

Error file

Client error boundary for descendants of the segment, not its own layout or template. In the 16.3+ documentation lane retry attempts fresh data and rendering; older versions require their documented recovery API. Never disclose raw server error details. Source: https://nextjs.org/docs/app/api-reference/file-conventions/error. Documentation-reviewed illustrative draft; installed declarations and runtime not verified.

Formal Syntax & Structure

nextjs syntaxnextjs
app/<segment>/error.tsx

Working Example

Example Snippetnextjs
'use client';export default function ErrorView({retry}:{error: Error & {digest?:string};retry:()=>void}){ return <section><h2>Catalog temporarily unavailable</h2><button type='button' onClick={()=>retry()}>Try again</button></section>;}
Next.js Reference