When an error occurs on a page, the error is intercepted by an error route.
The page is defined by src/app/error.tsx and it renders the component <PageError />
src/app/error.tsx
<PageError />
You can define specific error pages by adding an error.tsx file to a nested route, for instance inside the folder src/app/dashboard/
error.tsx
src/app/dashboard/
If a page route doesn't exist, the Not Found page is rendered.
Customize it by editing the file src/app/not-found.tsx
src/app/not-found.tsx
Learn more about Next.js Error Handlingarrow-up-right
Last updated 2 years ago