useAuthGate
Hook that sets up a listener for the firebase auth and updates the state whenever the user signs in/out, or the user's token refreshes.
This hook is not recommended to use in your app, but it's exposed in case you're doing something custom.
We recommend using the AuthGate
component instead, as seen in the quick example. useAuthGate
is the hook that is used by the AuthGate
.
You would use this if you were making a custom AuthGate
component and didn't want to use AuthGate
itself.
Usage
Okay, now that I got those disclaimers out of the way, here's how you use this hook:
Arguments
Accepts one optional argument. A dictionary with the following field:
onAuthStateChanged:
Optional function called whenever the auth state changes. Receives one argument:user
, which is eithernull
or a firebase user object.
Returns
A dictionary with the following:
user
either afirebase.User
ornull
loading
a boolean that tells you whether or not the auth listener is loading initially.
Last updated