Lesson

Choose Between authState or user to Subscribe to Firebase Authentication State Changes

You'll learn the 2 Observables that Firebase Authentication provides to subscribe to the authentication state of your application, authState and user.

Duration
1 min
Access
Free
Transcript
Available

You'll learn the 2 Observables that Firebase Authentication provides to subscribe to the authentication state of your application, authState and user.

You'll see how they both return the same User object from Firebase Authentication.

And you'll learn that the difference is that authState triggers when the user logs in, or logs out of the application, while user is called both of those times, and also is called when Firebase refreshes the user's authentication token.

As a personal guideline, if I need to do an operation when the user's token is refreshed (for example, update a 3rd party service) I'll use user, if not, I'll default to authState.