AuthGate
About
AuthGate
is a component that acts as the "gate" for your app's auth. It goes at the root of your app, inside of the DoormanProvider.
If you're using the withPhoneAuth
HOC, you have no usage for this component. It is only useful if you're using the component-based API with AuthFlow
. (See our quick example to learn the difference.)
Oversimplified Example
AuthGate
takes a function as a child, whose only argument is a dictionary containing a user
and loading
. The user
value comes from Firebase's auth, and it re-renders whenever there is a change in the auth state.
Under the hood, it implements firebase.onIdTokenChanged
, which is essentially the same thing as firebase.onAuthStateChanged
, with some added benefits.
Expanded Example
Below is the example from the AuthFlow Quick Example page.
Last updated