File conventions
Pages Router custom error files
Use dedicated 404 and 500 pages for missing and failed requests; _error is a more specialized fallback convention. Avoid including stack traces or private request details. Test production rather than assuming development error overlays behave like the deployed error UI. Example context: Next.js 16.x documentation lane; illustrative snippet or file tree, not executed. Exact candidate patch 16.4.6 remains unverified. Expected behavior / verification: Request an unknown path in the production fixture. Expect 404 and a usable home link. Test 500 through a separately controlled failing route; never force real production failures.
Formal Syntax & Structure
nextjs syntaxnextjs
pages/404.tsx; pages/500.tsx; pages/_error.tsxWorking Example
Example Snippetnextjs
// pages/404.tsxexport default function NotFoundPage() { return <main><h1>Page not found</h1><a href="/">Home</a></main>; }