Firebase Real-time Database in React

In this section, we'll be introduced to the Firebase Realtime Database and its functionality.

Storing User Data

So far, only Firebase knows about our users. There is no way to retrieve a single user or a list of users for our application from Firebase’s authentication database.

The users are stored internally by Firebase to keep the authentication secure. That’s good because we don’t need to be involved in storing sensitive data like passwords. However, we can introduce the Firebase Real-time Database to keep track of user entities ourselves.

It makes sense because then we can associate users with other domain entities (e.g. a message, a book, an invoice) created by them.

We should maintain a degree of control over our users, even if Firebase takes care of all the sensitive data.

This section will explain how we can store users in our Firebase Real-time Database. First, we must initialize the Real-time Database API for our Firebase class.

Initializing the Real-time Database API

This technique is identical to the one we used earlier for the authentication API:

Get hands-on with 1200+ tech skills courses.