Q16: How do custom 404 and 500 error pages work in the Pages Router?
pages/404.js: Static error page rendered at build time for missing routes.pages/500.js: Server error page pre-rendered or computed when server exceptions occur.
Custom 404 Page Definition
// pages/404.js
export default function Custom404() {
return <h1>404 - Page Not Found</h1>;
}💡 Next.js builds pages/404.js statically to serve instantly on missing route queries.
Key Takeaways
pages/404.jsis statically pre-rendered at build time.pages/500.jshandles unhandled server errors.
Knowledge Check
Is pages/404.js built as static HTML or dynamic SSR by default?