How to refresh user info with useAuth0() hook? - React


We are trying to enforce email verification manually in our React/Auth0 application (there’s a long complicated reason why it can’t be done via login rules). We are using useAuth0().user to check the email_verified status. Whenever a new page is loaded or the current page is refreshed/reloaded, the user info updates. However, I am trying to get the user to update without the page having to be fully loaded (ie, they are on a page that repeatedly updates and checks the email verification status, and is able to register that they have verified the email without them re-loading the page).

How are we able to refresh the user info from Auth0 without reloading the page?

I noticed there is a getCredentials hook for the react native sdk that will do that, but there doesn’t appear to be this call for the react sdk.

I have tried calling getAccessTokenSilently in multiple places and then checking the user data, but it does not change or update.

Also I’m sorry the tags are wrong, the UI is not giving me many options (ie I can’t select react or auth0, etc)

The solution is to call loginWithRedirect() it hits the /authorize endpoint and refreshes the user.