Read data from Cloud Firestore

Learn how to get data from the Cloud Firestore database and discover how to retrieve real-time data from Cloud Firestore.

There are multiple ways to read data from the Cloud Firestore database. The method used depends on the behavior desired for our application. Let’s dive into these methods!

Use the getDoc function

The getDoc function retrieves the contents of a single document in the database. As its argument, this function takes a reference to the document to be fetched. It returns a JavaScript promise that resolves with a snapshot of the document’s current content.

Within the document’s snapshot, we have access to some Javascript methods we can use to check each document’s existence and obtain the data inside it:

Get hands-on with 1200+ tech skills courses.