How to authenticate users using React and Firebase

Authenticating users is very hard to implement from scratch and you’ll have to write long lines of code in order to implement it but firebase makes it simple. In this article we will learn how to authenticate email and password using Firebase. We will start by setting up a project. After that, we will register a user and then we will log in with the same credentials to demonstrate the authentication.

Running the project

Now, type the below line in your terminal.

npm start 

After sometime, the compiled code starts running in http://localhost:3000 and you'll see the home page below.

When you will see home screen, click on register and register a user using your preferred email address and password.

If your authentication is successful, it’ll redirect you to dashboard page and you’ll see something similar to the image below.

You can confirm that the user was registered by going to the firebase site. In your firebase project, click on Authentication in the side bar. In the Users tab, you can see the email, date and time when the user was registered.

For further verification, you can login with the user credentials and you’ll get the user object in response which indicates that you are successfully logged in.

Voila! You made it to the end. Hope you enjoyed this lab.