# How to auto login in SPA?

**URL:** <https://community.auth0.com/t/how-to-auto-login-in-spa/169411>\
**Category:** Get Help\
**Tags:** login-experience, new-universal-login-experience\
**Created:** [January 20, 2025, 2:15pm UTC](https://community.auth0.com/t/how-to-auto-login-in-spa/169411 "2025-01-20T14:15:34Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![skorphil](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/skorphil/32/71028_2.png) [@skorphil](https://community.auth0.com/u/skorphil)\
**Post date:** [January 20, 2025, 2:15pm UTC](https://community.auth0.com/t/how-to-auto-login-in-spa/169411/1 "2025-01-20T14:15:34Z")

</div>

Hi, just setUp Auth0 to work with SPA with `useAuth0` hook. It is working overall but i have an issue:

After i reload the page, i got kinda logged out. And i need to manually press Login butt to be logged again (without login window and requesting a password).

I have noticed that this is because auth cookies are removed after i reload the page.

And here is the question: how to autologin after page reload?

---

<div class="post-metadata">

**Author:** ![skorphil](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/skorphil/32/71028_2.png) [@skorphil](https://community.auth0.com/u/skorphil)\
**Post date:** [January 20, 2025, 2:36pm UTC](https://community.auth0.com/t/how-to-auto-login-in-spa/169411/2 "2025-01-20T14:36:05Z")

</div>

Solved this with a help of (sorry cant add link - forum disable this)

```js
<Auth0Provider
      cacheLocation="localstorage" // here add "localstorage"

```

---

<div class="post-metadata">

**Author:** ![gerald.czifra](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/gerald.czifra/32/75301_2.png) [@gerald.czifra](https://community.auth0.com/u/gerald.czifra)\
**Post date:** [January 20, 2025, 4:31pm UTC](https://community.auth0.com/t/how-to-auto-login-in-spa/169411/3 "2025-01-20T16:31:36Z")

</div>

Hi @skorphil

Thank you for sharing this with the Community!

---

<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:** [February 3, 2025, 4:32pm UTC](https://community.auth0.com/t/how-to-auto-login-in-spa/169411/4 "2025-02-03T16:32:34Z")

</div>

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