How to fix custom 404 page not working in NextJS

Viewed 4706

I got stuck with custom 404 error page. I have created 404.js in pages folder following instruction in NextJS docs but it still uses default page in NextJS. Does anyone know this issue? Thank in advance.

Dependency:

"next": "9.2.2"

next.config.js just has env config.

1 Answers

According to their blog post about Next.js 9.3

This feature is fully backwards compatible so if you currently have a custom pages/_error.js it will continue to be used for the 404 page until you add pages/404.js.

pages/404.js is available starting from Next.js 9.3, either you can upgrade your dependency from 9.2.2 to 9.3 or use pages/_error.js stated as Documentation.

Related