0

In Nextjs you can declare 404 error like this:

return {notFound: true};

My question is how can I send additional data for my custom 404 page to show customized error text to users? Something like this:

return {notFound: true, props: {err:"Product was not found!"}}

And if I log props in my custom 404 page I get this:

export default function NotFound(props) {
   console.log(props) // output is: {err: undefined}
   return <Error statusCode={404} title="custom title" />
}
mrafei
  • 345
  • 1
  • 10

1 Answers1

0

Please refer to the doc. Static generated error page makes sence for reducing costs of loading error page, not dynamic genaration. So as long as using provided error pages, you can not achieve your custom error page with props.

iamippei
  • 148
  • 9