Repository navigation
Run Firebase Emulator locally
The Firebase Emulator Suite is a set of local development tools that lets you build and test Firebase apps without connecting to the actual Firebase backend. It provides emulated versions of several Firebase services, so you can develop and test your app locally before deploying it.
- Firestore: Test Firestore database reads/writes locally.
- Realtime Database: Simulate real-time sync of data.
- Authentication: Sign in users locally without real accounts.
- Cloud Functions: Run and debug serverless functions locally.
- Cloud Storage: Upload and retrieve files in a local storage emulator.
- Pub/Sub: Test message publishing (but not full behavior).
- No need to use the Firebase free quota.
- No network delay, instant updates.
- Work without an internet connection.
- No risk of modifying real data.
- Authentication
- Firestore
- Cloud Storage
- Cloud Function
1️⃣ Install Firebase CLI
npm install -g firebase-tools
2️⃣ Log in to Firebase (Optional for local testing)
firebase login
3️⃣ Initialize Firebase Emulator in your project
firebase init emulators
4️⃣ Start the emulator
firebase emulators:start
Now, you can interact with the emulated services on http://localhost:4000.
1️⃣ Get your laptop's IP Address
ipconfig | grep "192.168"
2️⃣ Copy your laptop's IP address, and open file firebase.json. Under emulators, replace <Add your IP address here> with IP address you copied above
"emulators": {
"auth": {
"host": "<Add your IP address here>",
"port": 9099
},
"functions": {
"host": "<Add your IP address here>",
"port": 5001
},
"firestore": {
"host": "<Add your IP address here>",
"port": 8080
},
"storage": {
"host": "<Add your IP address here>",
"port": 9199
},
"ui": {
"enabled": true
},
"singleProjectMode": true
},
3️⃣ Open file android/app/src/main/res/xml/network_security_config.xml, look for tag domain, and replace text replace with your IP Address with your IP address
<domain includeSubdomains="true">replace with your IP Address</domain>
4️⃣ In your lib/main.dart, after initialise Firebase app, add following lines, and replace host with your IP address above
if (kDebugMode) {
final String host = 'replace with your IP Address';
FirebaseFirestore.instance.useFirestoreEmulator(host, 8080);
FirebaseAuth.instance.useAuthEmulator(host, 9099);
FirebaseStorage.instance.useStorageEmulator(host, 9199);
}
5️⃣ Connect your test device to the same Wifi network as your laptop 6️⃣ Run ap
- Developing a chat app with Firestore or Realtime Database.
- Testing Firebase Authentication without creating real users.
- Debugging Cloud Functions locally before deploying.
- Working offline or in a restricted network.