# Invalid State, Anomaly detected when logging in with multiple tabs opened in Next js

**URL:** <https://community.auth0.com/t/invalid-state-anomaly-detected-when-logging-in-with-multiple-tabs-opened-in-next-js/101457>\
**Category:** Get Help\
**Tags:** classic-universal-login-experience, login-experience\
**Created:** [February 28, 2023, 11:03am UTC](https://community.auth0.com/t/invalid-state-anomaly-detected-when-logging-in-with-multiple-tabs-opened-in-next-js/101457 "2023-02-28T11:03:33Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![adeel](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/adeel/32/34106_2.png) [@adeel](https://community.auth0.com/u/adeel)\
**Post date:** [February 28, 2023, 11:03am UTC](https://community.auth0.com/t/invalid-state-anomaly-detected-when-logging-in-with-multiple-tabs-opened-in-next-js/101457/1 "2023-02-28T11:03:33Z")

</div>

Continuing the discussion from [Authentication fails (AnomalyDetected, Invalid State) after multiple tabs logout, login in old tab](https://community.auth0.com/t/authentication-fails-anomalydetected-invalid-state-after-multiple-tabs-logout-login-in-old-tab/58793/5):

The solution works when `cacheLocation='localstorage'` is given in react app  
**How can I do this in NextJs app ?**  
I cannot find any place where I can add the value for cacheLocation  
In NextJs, we do not create auth0 client with all values. It simply get values from the env

---

<div class="post-metadata">

**Author:** ![adeel](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/adeel/32/34106_2.png) [@adeel](https://community.auth0.com/u/adeel)\
**Post date:** [March 2, 2023, 6:17am UTC](https://community.auth0.com/t/invalid-state-anomaly-detected-when-logging-in-with-multiple-tabs-opened-in-next-js/101457/2 "2023-03-02T06:17:06Z")

</div>

Solution: This is the expected behaviour!

This is the [github issue](https://github.com/auth0/nextjs-auth0/issues/1090)

---

<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:** [March 2, 2023, 11:45am UTC](https://community.auth0.com/t/invalid-state-anomaly-detected-when-logging-in-with-multiple-tabs-opened-in-next-js/101457/3 "2023-03-02T11:45:37Z")

</div>

Thanks for sharing that with the rest of 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:** [March 16, 2023, 11:46am UTC](https://community.auth0.com/t/invalid-state-anomaly-detected-when-logging-in-with-multiple-tabs-opened-in-next-js/101457/4 "2023-03-16T11:46:08Z")

</div>

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