Home
Support Forums

Custom Next.js Error Page

We have a Next.js app being hosted on Netlify.

We are trying to create a custom error page which handles non-404 errors and Next.js suggests that we use an _error.js page in the pages/ folder to accomplish this. Locally this error page works when we cause a 500 error. However when it’s deployed to Netlify, causing a 500 error only gives us a JSON response instead of the error page.

We are using this plugin (GitHub - netlify/netlify-plugin-nextjs: A build plugin to integrate Next.js seamlessly with Netlify) to handle server-side rendering.

Hi there, @j.welton :wave:

Welcome to the Netlify Forums :netliconfetti: Thanks for your patience here. Are you still encountering this issue? If you are, have you checked out this blog post about making a custom 404 page in Next.js? I think it will be beneficial for you, and includes a link to the code.