Error Handling

Implement robust error handling to provide a better user experience and make debugging easier.

Custom 404 Not Found Page

Create a custom 404 page to provide a better user experience when visitors navigate to non-existent routes in your application.

File Location:

In Next.js 13+, you need to create a file named not-found.tsx in your app directory.

TypeScript
// app/not-found.tsx import Link from 'next/link' import { Button } from '@/components/ui/button'  export default function NotFound() {   return (     <div className="flex flex-col items-center justify-center min-h-[70vh] px-4 text-center">       <h1 className="text-4xl font-bold tracking-tight text-foreground/90 mb-2">404</h1>       <h2 className="text-2xl font-semibold text-foreground/80 mb-4">Page Not Found</h2>       <p className="text-muted-foreground mb-8 max-w-md">         The page you are looking for doesn't exist or has been moved.       </p>       <Button asChild>         <Link href="/">Return Home</Link>       </Button>     </div>   ) } 
SuperFast - Go From Idea to Revenue in Just Days | Product Hunt