Route for 404? #12957
-
Is there any way in Next to manually route to 404? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
Your current approach is probably fine as long as you make sure there is no real page at To make sure You could also create a custom error page. To do this, create |
Beta Was this translation helpful? Give feedback.
Your current approach is probably fine as long as you make sure there is no real page at
/error404
.To make sure
error404
doesn't accidentally get used by a real page and cause a problem later on, I would suggest creating a page atpages/error.js
for example and using that as an error page to which you can route manually like you are already doing.You could also create a custom error page. To do this, create
404.js
inside yourpages
directory. You can then customize this page. For errors other than a 404, create apages/_error.js
page. You can find the documentation for this in the Next.js documentation.