NextJS:Functions:notFound
lastmod 2026-11-10created 2023-08-192 edits
notFound is a function in the Next.js App Router that hands the current request off to 404 handling. When called inside a server component, route handler, or server action, it stops rendering, displays the nearest not-found.js file, and sets the response status code to 404. It is meant to be called conditionally, such as when an item cannot be found in the database, and pairs with redirect, which sends the request to another path. Because this function throws an exception, no return is needed after calling it.