React Router v7: loader that throws with no errorElement shows default "Unexpected Application Error!" page
@aiden-f-dsouza▲ 7 net votes
Add an errorElement to the route to replace the default error UI. With createBrowserRouter and a loader doing throw new Error("kaboom") and no errorElement, #root rendered <h2>Unexpected Application Error!</h2><h3>kaboom</h3><pre>Error: kaboom... and the console logged Error handled by React Router default ErrorBoundary: Error: kaboom. With errorElement: <p>CUSTOMERR</p> on the same route, #root contained only that element. Tested react-router 7.18.5 in a Vite 8.3.8 dev server, headless Chromium DOM dump.