QuickDevGuide

Home › Next.js

Error Handling — Next.js

Next.js provides built-in error handling through special files: error.tsx for runtime errors and not-found.tsx for 404 pages. error.tsx — Error Boundaries not-found.tsx — 404 Pages Triggering notFound() Error Hierarchy Errors bubble up to the nearest error.tsx boundary: global-error.tsx To catch errors in the root layout, use global-error.tsx:

Key Takeaways