Customize error message #78183
Replies: 2 comments
-
I've seen this issue happen when there's a network problem or slow connection, and the JS bundle (chunk file) fails to load. What u're seeing: "Application error: a client-side exception has occurred..." is actually the default fallback screen shown by Vercel or the React production error overlay. ✅ Here's what u can do to customize the message or make the error more user-friendly:
Create a global error boundary to catch unexpected errors and show a custom UI. // components/ErrorBoundary.tsx class ErrorBoundary extends React.Component { static getDerivedStateFromError(error: any) { componentDidCatch(error: any, info: any) { render() { Something went wrong. Please refresh the page or try again later.;}
} export default ErrorBoundary; Then wrap your _app.tsx like this: // pages/_app.tsx function MyApp({ Component, pageProps }) { export default MyApp;
If chunk loading fails and throws a hard crash, having a 500 page helps fallback gracefully: // pages/500.tsx Oops, something went wrong!This may be a network issue. Try refreshing the page. ); }
If u want to handle chunk load failure specifically, you can register an event listener: if (typeof window !== "undefined") { 📌 Summary:
|
Beta Was this translation helpful? Give feedback.
-
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Summary
When the network condition is poor and the chunk files are not completely downloaded, an error will occur on the page: "Application error: a client-side exception has occurred (see the browser console for more information)." How can we customize error message?
Additional information
No response
Example
No response
Beta Was this translation helpful? Give feedback.
All reactions