2.3.3: Firebase Authentication
Last updated
Last updated
Firebase Authentication allows us to authenticate our users with API calls instead of custom password-hashing or OAuth logic
How to set up Firebase Authentication with React
Firebase Authentication allows us to authenticate our apps' users, manage their accounts in the Firebase console and easily access user auth information from within our application. It makes authentication easy so we can focus on our app logic.
Start by reading the official Firebase Authentication tutorials linked below. Skip "Sign in with a pre-built UI" and "Get Started"; we will not use the former because it is currently incompatible with React 18, and we will go through the latter in the upcoming exercise.
We will primarily use email and password auth for learning. Feel free to use other forms of auth in your exercises and projects.
The Firebase Auth instances provides convenient access to the currently logged-in user. We can use this throughout our app.
Auth listeners provide a convenient way to trigger relevant components to re-render when a user logs in or out.
We will almost certainly want to retrieve current user from the Auth object in our apps, e.g. to display logged-in user in places such as navbars, profile pages and comment bars.
When you have successfully setup firebase authentication you can update your security rules for Firebase storage.