error.tsx file convention creates error boundaries that catch runtime errors in route segments.error and reset props for displaying messages and recovery.global-error.tsx at the root to catch errors in the root layout itself.1'use client';23export default function Error({4error,5reset,6}: {7error: Error & { digest?: string };8reset: () => void;9}) {10return (11<div className="error-container">12<h2>Something went wrong</h2>13<p>{error.message}</p>14// !mark15<button onClick={() => reset()}>Try again</button>16</div>17);18}
Error boundaries isolate failures to the nearest segment.
| Topic | Guidance |
|---|---|
| Error isolation | Errors in one segment do not crash the app |
| Recovery | Provide reset functionality and navigation options |
| Nested handling | Place error boundaries at different route depths |
| Root errors | Use global-error.tsx for root layout errors |








