Documentation

Read and search through all the Sitecore JSS documentation

Error Pages

Next.js supports custom Error Pages.

404 Page

The sample app provides a custom 404 Page.

The sample app will render the 404 Page in the following cases:

500 Page

The sample app provides custom 500 Page.

Next.js handles 500 errors, both client-side and server-side. This page is rendered in case of all errors except 404.

NOTE: 500 Page is only used in production. In development mode, you will get an error with the call stack.

If you want to handle specific status codes and render the built-in error page, you can by importing the Error component:

import Error from 'src/pages/_error';

const Page = ({ errorCode, text }) => {
  if (errorCode) {
    return <Error statusCode={errorCode} />
  }

  return <div>Content: {text}</div>
}

export default Page

Found a problem? Have something to add? Edit this on GitHub