# React/Apollo useAuth0 context is undefined when navigating to a page manually

**URL:** <https://community.auth0.com/t/react-apollo-useauth0-context-is-undefined-when-navigating-to-a-page-manually/61281>\
**Category:** Get Help\
**Tags:** auth0-spa-js, react\
**Created:** [April 17, 2021, 6:28pm UTC](https://community.auth0.com/t/react-apollo-useauth0-context-is-undefined-when-navigating-to-a-page-manually/61281 "2021-04-17T18:28:14Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![ronifintech](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/ronifintech/32/12835_2.png) [@ronifintech](https://community.auth0.com/u/ronifintech)\
**Post date:** [April 17, 2021, 6:28pm UTC](https://community.auth0.com/t/react-apollo-useauth0-context-is-undefined-when-navigating-to-a-page-manually/61281/1 "2021-04-17T18:28:15Z")

</div>

SDK: @auth0/auth0-react  
Version: 1.4.0  
React: 17.0.2

I utuilize `useAuth0` to access the context and parameters such as `isAuthenticated` and `user`.  
When I navigate through my App’s Header bar, everything works fine after I log in (e.g. isAuthenticated have the value `true`).  
However, if I go to my browser and type a specific route (e.g. [http://localhost:3000/profile](http://localhost:3000/profile)), the userAuth0() context gets erased and `isAuthenticated` returns false.

But, if I go to the Profile route through my Header bar, isAuthenticated returns true.

This is what my Auth0Provider looks like:

```
const Auth0ProviderWithHistory = ({children}: PropsWithChildren<{}>) => {

const onRedirectCallback = (appState: any) => {
    window.history.replaceState(
        {},
        document.title,
        appState && appState.targetUrl
            ? appState.returnTo
            : window.location.pathname
    );
}

return (
    <Auth0Provider
        domain={config.domain}
        clientId={config.clientId}
        audience={config.audience}
        // redirectUri={config.redirect_uri}
        redirectUri={window.location.origin}
        onRedirectCallback={onRedirectCallback}
        useRefreshTokens={true}
        cacheLocation="localstorage"
    >
        {children}
    </Auth0Provider>
);

```

};  
Any idea what’s happening here?

---

<div class="post-metadata">

**Author:** ![konrad.sopala](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/konrad.sopala/32/13516_2.png) [@konrad.sopala](https://community.auth0.com/u/konrad.sopala)\
**Post date:** [April 19, 2021, 12:16pm UTC](https://community.auth0.com/t/react-apollo-useauth0-context-is-undefined-when-navigating-to-a-page-manually/61281/3 "2021-04-19T12:16:32Z")

</div>

Hey there!

Can you open it as a GitHub issue in the auth0-spa-js repo so we can work on that directly with the repo maintainers? Once you do that please share the link to it with us here so we can ping repo maintainers. Thank you!

---

<div class="post-metadata">

**Author:** ![ronifintech](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/ronifintech/32/12835_2.png) [@ronifintech](https://community.auth0.com/u/ronifintech)\
**Post date:** [April 19, 2021, 12:52pm UTC](https://community.auth0.com/t/react-apollo-useauth0-context-is-undefined-when-navigating-to-a-page-manually/61281/4 "2021-04-19T12:52:51Z")

</div>

Thanks @konrad.sopala  
[https://github.com/auth0/auth0-react/issues/232](https://github.com/auth0/auth0-react/issues/232)

---

<div class="post-metadata">

**Author:** ![konrad.sopala](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/konrad.sopala/32/13516_2.png) [@konrad.sopala](https://community.auth0.com/u/konrad.sopala)\
**Post date:** [April 20, 2021, 12:31pm UTC](https://community.auth0.com/t/react-apollo-useauth0-context-is-undefined-when-navigating-to-a-page-manually/61281/5 "2021-04-20T12:31:24Z")

</div>

Perfect! I’ll ping repo maintainers in a few minutes

---

<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:** [May 5, 2021, 12:31pm UTC](https://community.auth0.com/t/react-apollo-useauth0-context-is-undefined-when-navigating-to-a-page-manually/61281/6 "2021-05-05T12:31:58Z")

</div>

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