# isAuthenticated of useAuth0 is too slow, why?

**URL:** <https://community.auth0.com/t/isauthenticated-of-useauth0-is-too-slow-why/72298>\
**Category:** Get Help\
**Tags:** react, login\
**Created:** [October 29, 2021, 6:45am UTC](https://community.auth0.com/t/isauthenticated-of-useauth0-is-too-slow-why/72298 "2021-10-29T06:45:05Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![mikan3rd](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/mikan3rd/32/32672_2.png) [@mikan3rd](https://community.auth0.com/u/mikan3rd)\
**Post date:** [October 29, 2021, 6:45am UTC](https://community.auth0.com/t/isauthenticated-of-useauth0-is-too-slow-why/72298/1 "2021-10-29T06:45:05Z")

</div>

We are using `@auth0/auth0-react` in our React app.  
After login, it takes about 10 seconds for `isAuthenticated` of `useAuth0` to become `true`.  
Why is it taking so long?  
Is there anything I can do to improve this?

- **Which SDK this is regarding:**  
`@auth0/auth0-react`

- **SDK Version:**  
`^1.3.0`

- **Platform Version:**  
react: 17.0.1

```auto
import { Loading } from '@/components/feedback/Loading';
import { useAuth0 } from '@auth0/auth0-react';
import React, { useContext, useEffect } from 'react';

export const LoginRestrictedRoute = ({ children }) => {
  const { isAuthenticated, isLoading, loginWithRedirect } = useAuth0();

  useEffect(() => {
    if (!isLoading && !isAuthenticated) {
     loginWithRedirect({
        appState: {
          targetUrl: window.location.href,
        },
      });
    }
  }, [isLoading, isAuthenticated]);

  if (isLoading || !isAuthenticated) {
    return <Loading loading={isLoading} size="large" />;
  }

  return children;
};

```

---

<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:** [October 29, 2021, 12:25pm UTC](https://community.auth0.com/t/isauthenticated-of-useauth0-is-too-slow-why/72298/2 "2021-10-29T12:25:10Z")

</div>

Hey there!

Can you open this as a GitHub issue in our react repo so we can get that addressed directly with the SDK maintainers? Once you have a link to it please share it here so we can ping them. Thank you!

---

<div class="post-metadata">

**Author:** ![mikan3rd](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/mikan3rd/32/32672_2.png) [@mikan3rd](https://community.auth0.com/u/mikan3rd)\
**Post date:** [October 29, 2021, 12:40pm UTC](https://community.auth0.com/t/isauthenticated-of-useauth0-is-too-slow-why/72298/3 "2021-10-29T12:40:24Z")

</div>

I’ve created an Issue here.

> <https://github.com/auth0/auth0-react/issues/291>
>
> \### Describe the problem
> 
> We are using \`@auth0/auth0-react\` in our React app.
> …
> After login, it takes about 10 seconds for \`isAuthenticated\` of \`useAuth0\` to become \`true\`.
> Why is it taking so long?
> Is there anything I can do to improve this?
> 
> ref: https://community.auth0.com/t/isauthenticated-of-useauth0-is-too-slow-why/72298
> 
> \### What was the expected behavior?
> 
> \`isAuthenticated\` should become \`true\` in about few second.
> 
> \### Reproduction
> 
> \`\`\`tsx
> import { Loading } from '@/components/feedback/Loading';
> import { useAuth0 } from '@auth0/auth0-react';
> import React, { useContext, useEffect } from 'react';
> 
> export const LoginRestrictedRoute = ({ children }) =\> {
> const { isAuthenticated, isLoading, loginWithRedirect } = useAuth0();
> 
> useEffect(() =\> {
> if (!isLoading && !isAuthenticated) {
> loginWithRedirect({
> appState: {
> targetUrl: window.location.href,
> },
> });
> }
> }, \[isLoading, isAuthenticated\]);
> 
> if (isLoading || !isAuthenticated) {
> return \<Loading loading={isLoading} size="large" /\>;
> }
> 
> return children;
> };
> \`\`\`
> 
> \### Environment
> \* \*\*Which SDK this is regarding:\*\*
> \`@auth0/auth0-react\`
> 
> \* \*\*SDK Version:\*\*
> \`^1.3.0\`
> 
> \* \*\*Platform Version:\*\* 
> react: 17.0.1

---

<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:** [October 29, 2021, 12:41pm UTC](https://community.auth0.com/t/isauthenticated-of-useauth0-is-too-slow-why/72298/4 "2021-10-29T12:41:24Z")

</div>

Perfect! I’ll ping them in a minute!

---

<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:** [November 13, 2021, 12:41pm UTC](https://community.auth0.com/t/isauthenticated-of-useauth0-is-too-slow-why/72298/5 "2021-11-13T12:41:48Z")

</div>

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