# Redirected temporarily to login page after refresh

**URL:** <https://community.auth0.com/t/redirected-temporarily-to-login-page-after-refresh/89494>\
**Category:** Get Help\
**Created:** [August 26, 2022, 2:24pm UTC](https://community.auth0.com/t/redirected-temporarily-to-login-page-after-refresh/89494 "2022-08-26T14:24:05Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![usaadi](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/usaadi/32/33302_2.png) [@usaadi](https://community.auth0.com/u/usaadi)\
**Post date:** [August 26, 2022, 2:24pm UTC](https://community.auth0.com/t/redirected-temporarily-to-login-page-after-refresh/89494/1 "2022-08-26T14:24:05Z")

</div>

Hello,

I’ve been using The React @auth0/auth0-react package in my app, and everything is working fine. But there is a slight problem that happens when I refresh the page when I’m authenticated.

The browser redirects to the login page for a few seconds, and then back to the original page. I’m using a ProtectedRoute component that uses withAuthenticationRequired. So, how can I remove this seemingly unnecessary redirect?

Thanks

```auto
import { withAuthenticationRequired } from "@auth0/auth0-react";
//import useIsDemoAccount from "../../components/shared/hooks/useIsDemoAccount";

export const ProtectedRoute = ({
  component,
  activeDateRange,
  transactionType,
  setSelectedTxType,
}) => {
  const Component = withAuthenticationRequired(component, {
    onRedirecting: () => <div>Loading...</div>,
  });

  return (
    <Component
      activeDateRange={activeDateRange}
      transactionType={transactionType}
      setSelectedTxType={setSelectedTxType}
    />
  );
};

export default ProtectedRoute;

```

---

<div class="post-metadata">

**Author:** ![ale.vesga1](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/ale.vesga1/32/60921_2.png) [@ale.vesga1](https://community.auth0.com/u/ale.vesga1)\
**Post date:** [November 27, 2024, 12:14am UTC](https://community.auth0.com/t/redirected-temporarily-to-login-page-after-refresh/89494/3 "2024-11-27T00:14:17Z")

</div>

Our team is going back to answer some frequently asked question.

This issue has to do with the `withAuthenticationRequired` method. Looking into the Auth0 documentation it describes the following:

> When you wrap your components in this Higher Order Component and an anonymous user visits your component they will be redirected to the login page; after login they will be returned to the page they were redirected from.

_(Reference: [withAuthenticationRequired | @auth0/auth0-react](https://auth0.github.io/auth0-react/functions/withAuthenticationRequired.html))_

Hope this helps someone!

---

<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:** [December 11, 2024, 12:15am UTC](https://community.auth0.com/t/redirected-temporarily-to-login-page-after-refresh/89494/4 "2024-12-11T00:15:10Z")

</div>

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