--- title: useAsyncError --- # useAsyncError [MODES: framework, data] ## Summary [Reference Documentation ↗](https://api.reactrouter.com/v7/functions/react_router.useAsyncError.html) Returns the rejection value from the closest [``](../components/Await). ```tsx import { Await, useAsyncError } from "react-router"; function ErrorElement() { const error = useAsyncError(); return (

Uh Oh, something went wrong! {error.message}

); } // somewhere in your app } />; ``` ## Signature ```tsx function useAsyncError(): unknown ``` ## Returns The error that was thrown in the nearest [`Await`](../components/Await) component