# Functionality of useAuth0 hook in react

**URL:** <https://community.auth0.com/t/functionality-of-useauth0-hook-in-react/63319>\
**Category:** Get Help\
**Tags:** auth0-spa-js, react\
**Created:** [May 25, 2021, 10:41am UTC](https://community.auth0.com/t/functionality-of-useauth0-hook-in-react/63319 "2021-05-25T10:41:47Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![harigovind2295](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/harigovind2295/32/29455_2.png) [@harigovind2295](https://community.auth0.com/u/harigovind2295)\
**Post date:** [May 25, 2021, 10:41am UTC](https://community.auth0.com/t/functionality-of-useauth0-hook-in-react/63319/1 "2021-05-25T10:41:47Z")

</div>

Hi Team,

I am using auth0-spa-js in my React code.

> const { user, getAccessTokenSilently } = useAuth0();

I am using getAccessTokenSilently method of useAuth0 hook to get the token for different users by creating some rules in Auth0. Once after triggering the method, i am getting the token which I am expecting.

But when I use the user variable provided by useAuth0 hook immediately after triggering the token method call, it still has the old user value which I expect it be updated with new user details. At times, user variable is getting updated with new user details, but I am not getting how exactly it works in the background.

> const { user } = useAuth0();

Can anyone please explain how & when the user variable provided by useAuth0 hook gets it’s value assigned.?

Thanks in advance,  
Hari.

---

<div class="post-metadata">

**Author:** ![stephanie.chamblee](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/stephanie.chamblee/32/26087_2.png) [@stephanie.chamblee](https://community.auth0.com/u/stephanie.chamblee)\
**Post date:** [May 26, 2021, 12:36pm UTC](https://community.auth0.com/t/functionality-of-useauth0-hook-in-react/63319/3 "2021-05-26T12:36:55Z")

</div>

Hi @harigovind2295,

The `user` is the decoded payload of the ID token that your app is issued after a user logs in or after silent authentication takes place.

To troubleshoot this, you can take a look at the network tab and find the request to `https://YOUR_DOMAIN/oauth/token`. The response will contain an Access Token and an ID Token. You can paste the ID Token [https://jwt.io/](https://jwt.io/) to verify that the user matches the ID Token claims.

Are you adding ID Token claims using rules or actions? If [silent authentication](https://auth0.com/docs/authorization/configure-silent-authentication), it’s possible that the rule or action is not able to add the custom claim if the data permanently saved on the user (e.g. stored in app metadata).

---

<div class="post-metadata">

**Author:** ![harigovind2295](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/harigovind2295/32/29455_2.png) [@harigovind2295](https://community.auth0.com/u/harigovind2295)\
**Post date:** [June 24, 2021, 5:00am UTC](https://community.auth0.com/t/functionality-of-useauth0-hook-in-react/63319/4 "2021-06-24T05:00:48Z")

</div>

Hi @stephanie.chamblee ,

Thanks for the reply. It helped me in implementing my requirement. Sorry for the delayed response.

Thanks,  
Hari

---

<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:** [June 28, 2021, 11:48am UTC](https://community.auth0.com/t/functionality-of-useauth0-hook-in-react/63319/5 "2021-06-28T11:48:07Z")

</div>

No worries! Glad it’s working now!

---

<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:** [June 28, 2021, 11:48am UTC](https://community.auth0.com/t/functionality-of-useauth0-hook-in-react/63319/6 "2021-06-28T11:48:09Z")

</div>


