Initialize the Firestore emulator

Jorge Vergara
InstructorJorge Vergara
Share this video with your friends

Social Share Links

Send Tweet
Published 3 years ago
Updated 2 years ago

Learn how to connect the Firestore emulator and explore it further in the Firebase Emulator Suite.

Instructor: We're going to initialize the Firestore emulator. For that, we're going to go to the file where we initialized Firebase. In my case, this is the app.module file. Then, we're going to look for the Firestore package and we're going add a new function here, it's called connectFirestoreEmulator.

Then, we're going to scroll to our Firestore initialization and we're going to call the connectFirestoreEmulator function. This function is going to take three parameters.

First, it's going to take the Firestore instance that we're using.Then, it's going to take the domain where we are running, -- in our case, this is localhost -- and then it's going to take the port as a number for where Firestore is running in the emulator.

If you don't know which port number we are using, you can go to the Firebase.JSON file, and there you can find firestore. In my case, you see that's 8080. Then I can add it here.

Now when I save my application, all of the calls are going to go through the emulator. For example, we have a demo application here that just adds records to the database. I'm going to click the add button and I'm going to say this is going to be Jorge's birthday.

Guests will pay 50 bucks and they were costing me $700. Then the date is going to be, I don't know, say November. Then I click create event and you can see that I can see it here in the application. If I go into the Firebase emulator suit, you can see here I have the users.

In my user, Jorge@jorgevergara.co, I have a collection named party. In here I can see the document that I just created. If I say, it's not 700. Let's say it's 900 and click save. You can see that if I go into the details of the event, it says 900 now. Ticket costs 50 bucks.

We can also change that and we can say now it's 75. When I click save, you can see that it immediately reloads in the application because all of the calls that we are doing are going against the emulator.

egghead
egghead
~ an hour ago

Member comments are a way for members to communicate, interact, and ask questions about a lesson.

The instructor or someone from the community might respond to your question Here are a few basic guidelines to commenting on egghead.io

Be on-Topic

Comments are for discussing a lesson. If you're having a general issue with the website functionality, please contact us at support@egghead.io.

Avoid meta-discussion

  • This was great!
  • This was horrible!
  • I didn't like this because it didn't match my skill level.
  • +1 It will likely be deleted as spam.

Code Problems?

Should be accompanied by code! Codesandbox or Stackblitz provide a way to share code and discuss it in context

Details and Context

Vague question? Vague answer. Any details and context you can provide will lure more interesting answers!

Markdown supported.
Become a member to join the discussionEnroll Today