📖 Scenario: You are building a local development environment for a Firebase project. You want to test your app's backend features without touching the live cloud services. This helps you develop safely and quickly.
🎯 Goal: Set up the Firebase Emulator Suite configuration to run Firestore and Authentication emulators locally.
📋 What You'll Learn
Create a Firebase configuration file with emulator settings
Add emulator ports for Firestore and Authentication
Configure the Firebase app to connect to the local emulators
Complete the setup so the app uses the emulators instead of live services
💡 Why This Matters
🌍 Real World
Developers use the Firebase Emulator Suite to test backend features locally without risking live data or incurring costs.
💼 Career
Knowing how to set up and use Firebase emulators is essential for safe and efficient Firebase app development and testing.
Progress0 / 4 steps
1
Create Firebase Emulator Configuration File
Create a file named firebase.json with a emulators section that includes firestore on port 8080 and auth on port 9099.
Firebase
Hint
The firebase.json file tells Firebase which emulators to run and on which ports.
2
Add Emulator Host Configuration Variables
In your app's main JavaScript file, create two constants named firestoreHost and authHost with values 'localhost' and ports 8080 and 9099 respectively.
Firebase
Hint
These constants will help your app connect to the local emulators.
3
Connect Firebase App to Local Emulators
Use the Firebase SDK functions connectFirestoreEmulator and connectAuthEmulator to connect your Firestore and Auth instances to the emulators using the constants firestoreHost, firestorePort, authHost, and authPort.
Firebase
Hint
These functions tell your app to use the local emulators instead of the live Firebase services.
4
Complete Emulator Suite Setup
Add the firebase emulators:start command to your package.json scripts section under the key start:emulators to run the Firebase Emulator Suite.
Firebase
Hint
This script lets you start all configured emulators with one command.
Practice
(1/5)
1. What is the main purpose of the Firebase Emulator Suite?
easy
A. To monitor live user data in real time
B. To deploy Firebase apps directly to production
C. To run Firebase services locally for safe app testing
D. To backup Firebase databases automatically
Solution
Step 1: Understand Firebase Emulator Suite role
The Emulator Suite runs Firebase services on your computer, not on the cloud.
Step 2: Identify its main use
It allows safe testing without affecting real data or users.
Final Answer:
To run Firebase services locally for safe app testing -> Option C
Quick Check:
Local testing = Safe app development [OK]
Hint: Emulator = local safe testing environment [OK]
Common Mistakes:
Confusing emulator with live deployment
Thinking it monitors real user data
Assuming it backs up data automatically
2. Which command starts the Firebase Emulator Suite with Firestore and Authentication emulators only?
easy
A. firebase emulators:start --only firestore,auth
B. firebase start --emulators firestore auth
C. firebase emulators:run firestore auth
D. firebase launch --services firestore,auth
Solution
Step 1: Recall correct Firebase CLI syntax
The command to start emulators uses 'firebase emulators:start' with '--only' to specify services.
Step 2: Match correct option
firebase emulators:start --only firestore,auth uses the exact syntax: 'firebase emulators:start --only firestore,auth'. Others are invalid commands.
Final Answer:
firebase emulators:start --only firestore,auth -> Option A