Skip to content

Firebase Emulator Suite — Local Development for Firestore, Functions, Auth, and More

DodaTech Updated 2026-06-28 3 min read

In this tutorial, you will learn about Firebase Emulator Suite. We cover key concepts, practical examples, and best practices to help you master this topic.

Firebase Emulator Suite provides local emulators for Firestore, Cloud Functions, Authentication, Storage, Hosting, and PubSub, enabling full local development without connecting to production Firebase services.

What You'll Learn

  • Setting up and configuring Firebase emulators
  • Using Cloud Functions and Firestore locally
  • Importing and exporting emulator data

Why It Matters

Local emulation speeds up development, reduces costs, and enables offline testing. No production data is affected. DodaTech developers use emulators for all Firebase feature development.

Code Examples

# Initialize emulators
firebase init emulators

# Select which emulators to install
# Firestore, Functions, Auth, Storage, Hosting, PubSub

# Start all emulators
firebase emulators:start

# Start specific emulators
firebase emulators:start --only firestore,auth

# Start with data import
firebase emulators:start --import=./emulator-data

# Export emulator data
firebase emulators:export ./emulator-data
// Connect app to emulators
import { getFirestore, connectFirestoreEmulator } from 'firebase/firestore';
import { getAuth, connectAuthEmulator } from 'firebase/auth';
import { getFunctions, connectFunctionsEmulator } from 'firebase/functions';

const db = getFirestore();
const auth = getAuth();
const functions = getFunctions();

if (location.hostname === 'localhost') {
  // Connect to local emulators
  connectFirestoreEmulator(db, 'localhost', 8080);
  connectAuthEmulator(auth, 'http://localhost:9099');
  connectFunctionsEmulator(functions, 'localhost', 5001);
}
// Firebase emulator configuration
// firebase.json emulator section
{
  "emulators": {
    "auth": {
      "port": 9099,
      "host": "0.0.0.0"
    },
    "firestore": {
      "port": 8080,
      "host": "0.0.0.0"
    },
    "functions": {
      "port": 5001,
      "host": "0.0.0.0"
    },
    "storage": {
      "port": 9199,
      "host": "0.0.0.0"
    },
    "hosting": {
      "port": 5000,
      "host": "0.0.0.0"
    },
    "pubsub": {
      "port": 8085,
      "host": "0.0.0.0"
    },
    "ui": {
      "enabled": true,
      "port": 4000
    }
  }
}
// Seed data for emulator Firestore
async function seedEmulatorData() {
  const db = getFirestore();

  // Create test users
  const users = [
    { name: 'Test User 1', email: 'test1@example.com', role: 'admin' },
    { name: 'Test User 2', email: 'test2@example.com', role: 'user' },
  ];

  for (const user of users) {
    await addDoc(collection(db, 'users'), user);
  }

  console.log('Test data seeded');
}
# Emulator UI access
# Open http://localhost:4000 in browser
# View Firestore documents, Auth users, Functions logs

# Run tests with emulators
firebase emulators:exec 'npm test'

Common Mistakes

1. Connecting to Production While Emulators Run

Ensure your app detects localhost and connects to emulators, not production.

2. Forgetting to Import Data Before Testing

Use firebase emulators:start --import to pre-populate emulators with seed data.

3. Not Using Emulators for CI/CD Tests

Run emulators in CI/CD for reliable, isolated integration tests.

4. Ignoring Emulator Limitations

Not all Firebase features are emulated. Check documentation for feature parity.

5. Using Production Security Rules Locally

Emulators support security rules. Use a separate rules file for development.

Practice Questions

  1. How do you start all Firebase emulators?
  2. How do you connect your app to local emulators?
  3. How do you seed test data in the emulator?
  4. How do you export emulator data for reuse?
  5. How do you run tests with emulators in CI/CD?

Answers:

  1. firebase emulators:start.
  2. Use connect*Emulator functions for each service.
  3. Run a seed script after starting emulators, or use --import with prepared data.
  4. firebase emulators:export ./data-path.
  5. firebase emulators:exec 'npm test'.

Challenge: Set up a complete Firebase development environment with emulators for Firestore, Auth, Functions, and Hosting. Create seed data scripts, configure CI/CD to run tests with emulators, and implement a hot-reload development workflow.

FAQ

Are all Firebase services available in the emulator?

Firestore, Auth, Functions, Storage, Hosting, and PubSub are emulated. Analytics, Crashlytics, and other services are not.

Can the emulator connect to production Firestore?

No. The emulator is completely isolated from production. Use import/export for data transfer.

Does the emulator support Firebase Extensions?

Emulator support for Extensions is limited. Check each extension's documentation.

How much memory do emulators use?

Each emulator uses 50-200 MB. Running all emulators may use 1-2 GB of RAM.

Can I use the emulator without Firebase CLI?

No. The emulators are managed through the Firebase CLI.

Mini Project

Set up a comprehensive Firebase development environment with all emulators. Create seed data scripts, implement hot-reload workflow for Functions, write integration tests that run against emulators in CI/CD, and set up a pre-commit hook that runs emulator tests.

What's Next

Review all Firebase concepts or explore Firebase extensions for pre-built integrations.

Built by the developers of DodaTech

Doda Browser, DodaZIP & Durga Antivirus Pro