Building Your App
Error Handling
Handle errors, 404s, and loading states with special files.
Three special files in any route folder control non-happy-path UI:
- error.tsx — rendered when a page throws
- not-found.tsx — rendered for unmatched routes (404)
- loading.tsx — a skeleton shown while data resolves
tsx
export default function NotFound() {
return <div><h1>404</h1><p>Page not found.</p></div>;
}