'Should I rely on nextjs 'pages/_error.js' for error handling or use React ErrorBoundary?

I'm using nextjs for quite a while now. I relied on _error.js page provided by nextjs when there is any error. In their doc here, it is specified to use errorboundary. Should I continue relying or next.js _error.js page or add errorboundary?



Solution 1:[1]

_error.js page is just a customization when the application throws a 500 error.

500 errors are handled both client-side and server-side by the Error component. If you wish to override it, define the file pages/_error.js and add the following code:

Error Boundaries are a React JS concept - Think of them as fallback components that can receive the error and display it or you can handle it yourself - It's considered as a best practice

They cover completely different areas of the stack.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Ramakay