일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | |||||
3 | 4 | 5 | 6 | 7 | 8 | 9 |
10 | 11 | 12 | 13 | 14 | 15 | 16 |
17 | 18 | 19 | 20 | 21 | 22 | 23 |
24 | 25 | 26 | 27 | 28 | 29 | 30 |
- HTML
- JavaScript
- typeScript
- nextJS
- node.js
- error
- REACT
- graphQL
- express.js
- middleware
- API
- concept
- solidity
- Ethereum
- evm
- hardhat
- Interface
- bitcoin
- Redux
- tailwindcss
- web
- Props
- built in object
- SSR
- blockchain
- 기준
- CLASS
- useState
- 삶
- CSS
- Today
- Total
ReasonJun
Next.js : Error Handling 본문
Error handling is an important aspect of any web application, especially when working with Next.js. Next.js provides different ways to handle errors in development, server-side, and client-side scenarios. In this article, we will explore some of the best practices for error handling in Next.js 13.
In development mode, Next.js shows an overlay that covers the webpage when there is a runtime error. This overlay helps developers to quickly identify and fix the error. The overlay will disappear once the error is resolved.
For server-side errors, Next.js provides a default 500 page that can be customized by creating a pages/500.js file. This page will be rendered when there is an error on the server that cannot be handled by the application logic. The 500 page should not expose any sensitive information to the app user, but rather provide a generic message and a way to contact support.
For client-side errors, Next.js recommends using React Error Boundaries, which are class components that can catch JavaScript errors in their child components and render a fallback UI. Error Boundaries can also log error information and provide a way to reset the application state. To use Error Boundaries in Next.js, we need to create an ErrorBoundary component and wrap it around the Component prop in pages/_app.js file.
https://nextjs.org/docs/app/building-your-application/routing/error-handling
https://react.dev/reference/react/Component#catching-rendering-errors-with-an-error-boundary
'Frontend > Next.js' 카테고리의 다른 글
Next.js : 13 version (0) | 2023.06.21 |
---|---|
Next.js : useRouter / Link (0) | 2023.06.21 |
Next.js : Measuring performance (webVitalsAttribution) (0) | 2023.06.21 |
Next.js : Custom App / Document / Error page (0) | 2023.06.21 |
Next.js : Absolute Imports and Module Path Aliases (0) | 2023.06.21 |