# Auth0-React State

**URL:** <https://community.auth0.com/t/auth0-react-state/115943>\
**Category:** Get Help\
**Tags:** sdks-quickstarts, auth0-react\
**Created:** [September 11, 2023, 8:13pm UTC](https://community.auth0.com/t/auth0-react-state/115943 "2023-09-11T20:13:12Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![KimberlyRamirez](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/kimberlyramirez/32/50738_2.png) [@KimberlyRamirez](https://community.auth0.com/u/KimberlyRamirez)\
**Post date:** [September 11, 2023, 8:13pm UTC](https://community.auth0.com/t/auth0-react-state/115943/1 "2023-09-11T20:13:12Z")

</div>

I am using Cypress for E2E testing and Auth0-React. Currently I am programmatically logging into the app I need to test in my Cypress project. I use a PKCE flow to get a auth0 token to login, and then store that token in local storage. That is all working great, but here is my issue, in the app, we use the auth0-react library for dev/prod login and it stores user info in a user object. When I am using Cypress auth0-react is not being used so the user object is undefined. However, we rely on that user object throughout a lot of the app, so I would have to check for if there’s a token in local storage, parse it, and such everywhere we use it. Is there an easier way? I’ve looked all over but haven’t found anything. TIA

---

<div class="post-metadata">

**Author:** ![ty.frith](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/ty.frith/32/58484_2.png) [@ty.frith](https://community.auth0.com/u/ty.frith)\
**Post date:** [September 11, 2023, 10:33pm UTC](https://community.auth0.com/t/auth0-react-state/115943/3 "2023-09-11T22:33:03Z")

</div>

Hey there @KimberlyRamirez welcome to the community!

> [@KimberlyRamirez](#):
>
> However, we rely on that user object throughout a lot of the app, so I would have to check for if there’s a token in local storage, parse it, and such everywhere we use it. Is there an easier way? I’ve looked all over but haven’t found anything. TIA

Hmm that’s a bit tricky not using auth0-react at all - From what I’ve seen testing typically looks like what is outlined in [this blog post](https://auth0.com/blog/end-to-end-testing-with-cypress-and-auth0/) _using_ auth0-react. That being said, in your environment perhaps you could just mock the user object? I have definitely seen this done as well.

Keep us posted?

---

<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:** [September 25, 2023, 10:33pm UTC](https://community.auth0.com/t/auth0-react-state/115943/4 "2023-09-25T22:33:19Z")

</div>

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