react-firebase-hooks icon indicating copy to clipboard operation
react-firebase-hooks copied to clipboard

Feature request. New hook to monitor updates for the current user.

Open chrisbianca opened this issue 4 years ago • 2 comments

The useAuthState hook only updates if the user logs in or logs out and not if the user updates in any way. This is a limitation of the underlying onAuthStateChange method described here: https://firebase.google.com/docs/reference/js/firebase.auth.Auth#onauthstatechanged

Proposal New useCurrentUser hook which listens to updates to the user as well as login / logout events

Thoughts This is likely to need a few things:

  • A context provider that sits at the top level of the application and stores the current user
  • A series of hooks that wrap each of the update methods available in Firebase Auth and updates the user within the context

See https://github.com/CSFrequency/react-firebase-hooks/issues/108 for further background.

chrisbianca avatar Apr 24 '21 07:04 chrisbianca

Has there been any updates on this? its exactly what I need for an app I'm working on.

taylorchance avatar Feb 13 '22 16:02 taylorchance

Is there a reason you couldn't use onIdTokenChanged - It seems like this updates any time a user logins/logs out AND whenever the id token refreshes.

Is there a reason you wouldn't want to use that as the higher-level state? Could we make this an optional config in the the useAuthState object or create a new hook useLegacyAuthState

mljlynch avatar Dec 21 '22 21:12 mljlynch