createAuth0Client takes 5+ seconds after login from redirect

@auth0/auth0-spa-js createAuth0Client method takes over 5 seconds to complete every time a user logs in. Even after waiting, getTokenSiliently also takes another 5 seconds. That seems ridiculous on a high speed internet, is it normal? (code below, please excuse the lazy perf checking)

The provider is passed proper credentials, redirect_uri

  useEffect(() => {
    const initAuth0 = async () => {
      console.log('I still run!!!')
      const now =;
      console.log('starting login', now);
      const auth0FromHook = await createAuth0Client(initOptions);
      console.log('created client', - now)

      if ('code=')) {
        console.log('calling redirect')
        const { appState } = await auth0FromHook.handleRedirectCallback();

      const isAuthenticatedP = auth0FromHook.isAuthenticated();
      const tokenP = auth0FromHook.getTokenSilently();
      const isAuthenticated = await isAuthenticatedP;
      console.log('is authenticated', isAuthenticated, - now);


      if (isAuthenticated) {
        const token = await tokenP;
        const user = await auth0FromHook.getUser();
        console.log('got tokes', - now);
        const meteorStart =;
        console.log('starting call to meteor login', meteorStart);

        Meteor.loginWithIntelage({ token }, () => {
          const meteorUser = Meteor.user();
          const combinedUserData = { ...user, ...meteorUser };
          console.log('finish call to meteor', - meteorStart);
          console.log('metoer user', meteorUser, loggingIn);
          console.log('user', user);
      } else {
        // redirect
      console.log('finish auth', - now);
  }, []);

Additional details:

Its very slow only on login from a redirect, if the user already has the cookie required, it usually takes like 1/2 a second to do what takes 5 or 10 seconds after redirecting from our universal login page.

Update for others: I’ve been working on this with @goofiw in a support ticket as well. I think we narrowed the issue down to this change:

This is a change to prevent a race condition and it’s only supposed to hold up the application until it can get the token from the cache. For some reason we’re getting the full 5 second timeout in this case. Continuing to investigate. If you’ve experienced this problem please share here.

1 Like

Thanks @matt.macadam for letting us know!

@matt.mcadam I am also experiencing this in my app in the same circumstances as @goofiw. The delay is consistently around 5 seconds. Any known workarounds?

I am using the Universal Login with passwordless authentication and just changed to use a magic link instead of a code. This eliminates the problem.

1 Like

Thanks a lot for sharing it with the rest of community @ddewinter!

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