useAuth0() call is much slower in an inactive browser tab

Please include the following information in your post:

  • Which SDK this is regarding: auth0-react
  • SDK Version: 1.11.0

I am using the React SDK and calling useAuth0() to check if the user is authenticated and calling loginWithRedirect if the user is not authenticated:

    const { isLoading, isAuthenticated, loginWithRedirect } = useAuth0();

    if (isLoading) {
        return <div class="p-4">Loading...</div>;
    }

    if (!isAuthenticated) {
        loginWithRedirect({
            appState: {
                targetUrl: window.location.href
            }
        });
    }

This is working fine but I have noticed that the call to useAuth0() seems to take a lot longer when the browser tab is inactive, i.e. if you open a link in a new browser tab, the call takes around 2-3x longer if the tab is inactive compared to when you click into the tab to activate it.

Any idea why this would be happening?