Refresh React useAuth0 user after API user data update

Hello from Belgium. I have a web React application accessing users data through useAuth0 hook (from npm auth0-react package). In the profile page, I permit the connected user to change his profile picture. The new picture URL is send to a nodejs server which send it to the user metadata through auth0 API endpoint. Everything works smoothly and perfectly.

The problem is that, to make useAuth0 user update with the new URL, I have no other choice than refreshing the browser page (and thus the entire React app). What I would like, of course, would be to force useAuth0 to refresh its user data automatically (as a useState would do) or at least programmaticaly (when my nodejs server has recieved the code 200 from the API call). In other words, any idea on how I could force useAuth0 to “refresh” itself ?

Thank you very much in advance :slight_smile:

1 Like

OK, at the end it was as easy as manually updating useAuth0().user as soon as the nodejs server returned from its updating process. Don’t know if there is a better/proper way of obtaining that result, but at least it works and has no netword overload.

2 Likes

Perfect thanks for sharing that with the rest of community!

1 Like