Next.js Typescript error page
✓ Published0🌍 Public
TTipTopCoder
Last edited Feb 15, 2020
Created on Feb 15, 2020
This example shows a Next.js custom error page that displays either a server-side or client-side error message based on the HTTP status code. It uses Next.js’s `getInitialProps` lifecycle method to retrieve the status code from the `res` or `err` objects in the `NextPageContext`. The component conditionally renders text indicating whether the error occurred on the server or client, defaulting to a 404 status if no error is present. The code relies on React’s functional component pattern and Next.js’s built-in error handling.
AI-generated description