import { Toaster } from "react-hot-toast" ; import { AppProps , ErrorBoundary , ErrorComponent , AuthenticationError , AuthorizationError , ErrorFallbackProps , useQueryErrorResetBoundary , } from "blitz" ; export default function App ( { Component , pageProps } ) { const getLayout = Component . getLayout || ( ( page ) => page ) ; return ( < ErrorBoundary FallbackComponent = { RootErrorFallback } onReset = { useQueryErrorResetBoundary ( ) . reset } > { getLayout ( < > < Component { ... pageProps } / > < Toaster position = "bottom-right" toastOptions = { { duration : 5000 , } } /> < />)} < /ErrorBoundary>); } function RootErrorFallback ( { error , resetErrorBoundary } ) { if ( error instanceof AuthenticationError ) { return < ErrorComponent statusCode = { error . statusCode } title = "You are not logged in" / > ; } else if ( error instanceof AuthorizationError ) { return ( < ErrorComponent statusCode = { error . statusCode } title = "Sorry, you are not authorized to access this" / > ) ; } else { return ( < ErrorComponent statusCode = { error . statusCode || 400 } title = { error . message || error . name } / > ) ; } }