How to check if user has logged out in another tab?

I have created an SPA using auth0-react. If I start with two logged in tabs of my web application and logout in one tab of my browser, what function, variable, or technique can I use to detect that the user is no longer logged in when I switch to the other tab? This would prevent the user from making any changes in the application until the user logs in again.

Hi @denyomonogatari,

Welcome to the Community!

I am doing some research on this and I will let you know what I find!

Stephanie

It looks like if you set the cacheLocation on the Auth0Provider to ‘localstorage’ other tabs will be able to pick up that the user has logged out.

ReactDOM.render(
  <Auth0Provider
    domain={config.domain}
    clientId={config.clientId}
    audience={config.audience}
    redirectUri={window.location.origin}
    onRedirectCallback={onRedirectCallback}
    useRefreshTokens={true}
    cacheLocation="localstorage"
  >
    <App />
  </Auth0Provider>,
  document.getElementById("root")
);

Note about local storage from this topic:

Just what I needed thank you!
For the sake of completeness I can catch the OAuthError when trying to call getAccessTokenSilently().

Thanks for including the getAccessTokenSilently piece!

Previous message deleted due to SPAM reasons.