# isAuthenticated failing on refresh

**URL:** <https://community.auth0.com/t/isauthenticated-failing-on-refresh/186109>\
**Category:** Get Help\
**Tags:** authentication-sessions, sessions\
**Created:** [April 29, 2025, 8:24pm UTC](https://community.auth0.com/t/isauthenticated-failing-on-refresh/186109 "2025-04-29T20:24:40Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![roamingstars](https://upload.wikimedia.org/wikipedia/commons/thumb/7/7c/User_font_awesome.svg/768px-User_font_awesome.svg.png) [@roamingstars](https://community.auth0.com/u/roamingstars)\
**Post date:** [April 29, 2025, 8:24pm UTC](https://community.auth0.com/t/isauthenticated-failing-on-refresh/186109/1 "2025-04-29T20:24:40Z")

</div>

I’m writing a React web app and I’m creating a new auth0Client in my `useEffect` on every mount. I’m having users log in with `loginWithPopup`. Then I’m checking `isAuthenticated` and `getUser`, both of which work fine, until I refresh the page. Then, `isAuthenticated` returns false.

Am I misunderstanding something about how Auth0 handles sessions? What is the recommended way to maintain state (specifically the user being authenticated) between refreshes?

---

<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:** [April 29, 2025, 9:50pm UTC](https://community.auth0.com/t/isauthenticated-failing-on-refresh/186109/3 "2025-04-29T21:50:59Z")

</div>

Hi @roamingstars,

Welcome back to the Auth0 Community!

The reason the user is being logged out after a page refresh when using the React SDK might be the lack of implementing the [onRedirectCallback](https://auth0.github.io/auth0-react/interfaces/Auth0ProviderOptions.html#onRedirectCallback) function found on the Auth0 Provider, which removes the state and code parameters from the URL after being redirected from the authorize page so that the Callback URL is stil valid.

This is a code snippet of implementing it:

```auto
const onRedirectCallback = (appState) => {
  history.push(
    appState && appState.returnTo ? appState.returnTo : window.location.pathname
  );
};

```

referenced in the [State and Code Parameters Stuck in URL react-auth0 - User Getting Logged Out on Page Refresh](https://community.auth0.com/t/state-and-code-parameters-stuck-in-url-react-auth0-user-getting-logged-out-on-page-refresh/148408) article.

I hope this helps!  
Best regards,  
Remus

---

<div class="post-metadata">

**Author:** ![roamingstars](https://upload.wikimedia.org/wikipedia/commons/thumb/7/7c/User_font_awesome.svg/768px-User_font_awesome.svg.png) [@roamingstars](https://community.auth0.com/u/roamingstars)\
**Post date:** [April 30, 2025, 12:19am UTC](https://community.auth0.com/t/isauthenticated-failing-on-refresh/186109/4 "2025-04-30T00:19:58Z")

</div>

Forgive me for my confusion, but why do I need to handle a redirect if I’m using `loginWithPopup`?

---

<div class="post-metadata">

**Author:** ![roamingstars](https://upload.wikimedia.org/wikipedia/commons/thumb/7/7c/User_font_awesome.svg/768px-User_font_awesome.svg.png) [@roamingstars](https://community.auth0.com/u/roamingstars)\
**Post date:** [April 30, 2025, 2:30pm UTC](https://community.auth0.com/t/isauthenticated-failing-on-refresh/186109/5 "2025-04-30T14:30:31Z")

</div>

I figured out the issue. I tried switching browsers from Brave to Chrome, and `isAuthenticated` started returning true even after page refreshes. Then I returned to Brave and disabled Brave Shields, and suddenly everything started working.

It seems the issue was with Brave’s security settings. There was no issue on Auth0’s part.

---

<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:** [April 30, 2025, 3:08pm UTC](https://community.auth0.com/t/isauthenticated-failing-on-refresh/186109/6 "2025-04-30T15:08:35Z")

</div>

Hi @roamingstars,

Thanks for providing your solution.

Indeed browsers that block 3rd party cookies can cause this type of issue since silent authentication can not take place anymore. I’m leaving this documentation here as well, that talks about [Authentication Lost after Refreshing an SPA](https://community.auth0.com/t/authentication-lost-after-refreshing-an-spa/117733) since it might help others as well.

Thanks,  
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:** [May 14, 2025, 3:08pm UTC](https://community.auth0.com/t/isauthenticated-failing-on-refresh/186109/7 "2025-05-14T15:08:54Z")

</div>

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