just create another route for the error page at the end using wildcard
const router = createBrowserRouter([
{
path: '/',
element: <App />,
children: [ ... ],
},
{
path: "*", // use wildcard path (*)
element: <ErrorPage />,
},
]);