Next.js · Junior · Question 13 of 75
How do you show a 404 page for a nonexistent product in a server page?
- ✓Correct answer: Call
notFound()fromnext/navigation - 2Return
{ status: 404 }from the page component - 3Throw
new Error('404')- Next.js will figure it out
Explanation
notFound() stops rendering, shows the nearest not-found.tsx (or the default 404) and sets the appropriate status. A component can't return an HTTP status, and a regular error goes to error.tsx.