Handle errors with error.tsx - catches errors in the child tree and shows fallback UI. Layouts stay visible.
Every layout and page is wrapped in an error boundary that resets on navigation. Add error.tsx in a folder for custom fallback UI. It is a special file - it does not create a URL. Nearest-wins applies.
| File | Purpose |
|---|---|
| src/app/error.tsx | Fallback for routes without a closer error file |
| src/app/dashboard/error.tsx | Dashboard segment only |
| src/app/blog/[slug]/error.tsx | Blog post segment only |
Create error.tsx in any folder for that route and its children. The file default-exports a React component that receives error and reset.
The component receives two props from the boundary.
| Prop | Type | Description |
|---|---|---|
| error | Error | Thrown Error object with message and stack |
| reset | () => void | Clears error state and re-renders children |
Place error.tsx in subdirectories. Each only catches errors in its subtree.
| Route | Error Boundary Used |
|---|---|
| /blog/hello-world | src/app/blog/error.tsx |
| /dashboard | src/app/dashboard/error.tsx |
| /dashboard/settings | src/app/dashboard/settings/error.tsx |
| /about | src/app/error.tsx (global fallback) |
The closest error.tsx to the route where the error occurred is used.
error.tsxError UI is shown inside the layout hierarchy. Headers, sidebars, and nav stay visible when a child route errors.
If no error.tsx exists in scope, Bini.js uses a built-in fallback.
bini-overlay can show the error__bini_error__ CustomEvent on window for external overlaysSpecial files do not create URLs. Pages do.
| File | Role |
|---|---|
| error.tsx | Segment error boundary |
| layout.tsx | Wraps segment + children |
| page.tsx | Route content |
| loading.tsx | Suspense fallback |
Show a fallback while pages and layouts load.
Wrap each page individually inside the layout chain.
Handle unmatched URLs with a custom 404 page.
Create your first pages and wrap them in shared layouts.
Define routes with folders and page files inside them.
How every route is pre-rendered to HTML at build time.
Handle errors with error.tsx - catches errors in the child tree and shows fallback UI. Layouts stay visible.
Every layout and page is wrapped in an error boundary that resets on navigation. Add error.tsx in a folder for custom fallback UI. It is a special file - it does not create a URL. Nearest-wins applies.
| File | Purpose |
|---|---|
| src/app/error.tsx | Fallback for routes without a closer error file |
| src/app/dashboard/error.tsx | Dashboard segment only |
| src/app/blog/[slug]/error.tsx | Blog post segment only |
Create error.tsx in any folder for that route and its children. The file default-exports a React component that receives error and reset.
The component receives two props from the boundary.
| Prop | Type | Description |
|---|---|---|
| error | Error | Thrown Error object with message and stack |
| reset | () => void | Clears error state and re-renders children |
Place error.tsx in subdirectories. Each only catches errors in its subtree.
| Route | Error Boundary Used |
|---|---|
| /blog/hello-world | src/app/blog/error.tsx |
| /dashboard | src/app/dashboard/error.tsx |
| /dashboard/settings | src/app/dashboard/settings/error.tsx |
| /about | src/app/error.tsx (global fallback) |
The closest error.tsx to the route where the error occurred is used.
error.tsxError UI is shown inside the layout hierarchy. Headers, sidebars, and nav stay visible when a child route errors.
If no error.tsx exists in scope, Bini.js uses a built-in fallback.
bini-overlay can show the error__bini_error__ CustomEvent on window for external overlaysSpecial files do not create URLs. Pages do.
| File | Role |
|---|---|
| error.tsx | Segment error boundary |
| layout.tsx | Wraps segment + children |
| page.tsx | Route content |
| loading.tsx | Suspense fallback |
Show a fallback while pages and layouts load.
Wrap each page individually inside the layout chain.
Handle unmatched URLs with a custom 404 page.
Create your first pages and wrap them in shared layouts.
Define routes with folders and page files inside them.
How every route is pre-rendered to HTML at build time.