Next.js · Junior · Question 13 of 75

How do you show a 404 page for a nonexistent product in a server page?

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.

Further reading

Problem with a question

Next.js · Junior · question 13

Test yourself

Take the Next.js · Junior quiz: questions and options are shuffled, and you get a review of your mistakes at the end.

Take this quiz