# Error handling with auth0-react

**URL:** <https://community.auth0.com/t/error-handling-with-auth0-react/150167>\
**Category:** Get Help\
**Tags:** sdks-quickstarts, auth0-react\
**Created:** [October 21, 2024, 3:08am UTC](https://community.auth0.com/t/error-handling-with-auth0-react/150167 "2024-10-21T03:08:52Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![steven.m.wexler](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/steven.m.wexler/32/61572_2.png) [@steven.m.wexler](https://community.auth0.com/u/steven.m.wexler)\
**Post date:** [October 21, 2024, 3:08am UTC](https://community.auth0.com/t/error-handling-with-auth0-react/150167/1 "2024-10-21T03:08:52Z")

</div>

I have Auth0 working effectively in my React app. Now, I am trying to track down edge cases to recover/respond when users hit errors. I see that `useAuth0` returns an error. But I don’t see a list of the potential errors it can return or recommendations for how to respond to the different errors.

Is a list of the possible errors. And is there guidance for handling errors returned from `useAuth0`?

Here is what I have:

```auto
import {useAuth0} from "@auth0/auth0-react";

export const onAuthError = async (error: Error, isAuthenticated: boolean, logout: (options?: LogoutOptions) => Promise<void>) => {
    errorService.notify(error); //This is my error tracking. (We use Bugsnag)
    localStorage.clear();
    //log error to my error service
    if (isAuthenticated) {
        await logout();
    }
    if (window.location.pathname !== "/login") {
        window.location.href = "/login";
    }
};

const MyApp = () => {
    const {isAuthenticated, getAccessTokenSilently, user, isLoading, error, logout} = useAuth0();
    useEffect(() => {
        if (error) {
            onAuthError(error, isAuthenticated, logout);
        }
    }, [error]);
};

```

Same question is on StackOverflow: [reactjs - How to recover from Auth0 Errors - Stack Overflow](https://stackoverflow.com/questions/79094666/how-to-recover-from-auth0-errors)

---

<div class="post-metadata">

**Author:** ![remus.ivan](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/remus.ivan/32/68771_2.png) [@remus.ivan](https://community.auth0.com/u/remus.ivan)\
**Post date:** [January 23, 2025, 7:44pm UTC](https://community.auth0.com/t/error-handling-with-auth0-react/150167/3 "2025-01-23T19:44:17Z")

</div>

Hello @steven.m.wexler,

Welcome to the Auth0 Community,

A list of possible errors can be found under [this documentation](https://auth0.com/docs/libraries/auth0js?_gl=1*1g8atdb*_gcl_au*MTEzMjcyMTIxNS4xNzM0NTI1MDYz*_ga*MTk5NDI5MjUzNy4xNzM0NTI1MDYz*_ga_QKMSDV5369*MTczNzY1NjMwNy45NC4xLjE3Mzc2NjA0MTUuNjAuMC4w#error-codes-and-descriptions).  
You can also check the [Common Auth0 Library Authentication Errors](https://auth0.com/docs/libraries/common-auth0-library-authentication-errors?_gl=1*15hz0ug*_gcl_au*MTEzMjcyMTIxNS4xNzM0NTI1MDYz*_ga*MTk5NDI5MjUzNy4xNzM0NTI1MDYz*_ga_QKMSDV5369*MTczNzY1NjMwNy45NC4xLjE3Mzc2NjAxNzAuMzUuMC4w#sign-up) and the [Log Event Type Codes](https://auth0.com/docs/deploy-monitor/logs/log-event-type-codes?_gl=1*k5mp4p*_gcl_au*MTEzMjcyMTIxNS4xNzM0NTI1MDYz*_ga*MTk5NDI5MjUzNy4xNzM0NTI1MDYz*_ga_QKMSDV5369*MTczNzY1NjMwNy45NC4xLjE3Mzc2NjEwMzguNDMuMC4w) might come in handy as well.

Thank you for your post and I hope this helped.  
Remus

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/auth0/original/3X/b/5/b560f266932fcce5d57f09a6595bd50518cae3f3.jpeg) [@system](https://community.auth0.com/u/system)\
**Post date:** [February 6, 2025, 7:44pm UTC](https://community.auth0.com/t/error-handling-with-auth0-react/150167/4 "2025-02-06T19:44:25Z")

</div>

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.
