What is the Firebase Local Emulator?
The Firebase Local Emulator is essentially a collection of tools that allows developers to run features of Firebase products such as Firestore, Firebase Authentication, Realtime Database, Cloud Functions and more locally on the computer. This offers the advantage of being able to check your code changes immediately without transferring them to the cloud.
Advantages of the Firebase Local Emulator:
- Faster development timeSince everything runs locally, the response times are much faster than for tests in the cloud.
- Cost savingsTests performed locally do not incur any additional costs that would normally be incurred with cloud-based operations.
- SecurityBecause we work locally, there is no risk of compromising real data or inadvertently exposing sensitive information.
How do you set up the emulator?
Getting started is quite simple. After installing the Firebase CLI tool, all you have to do is enter the command firebase init emulators to start the emulator. We can then select and configure the desired services.
A simple example: Emulate Firestore database locally
Once the emulator has been set up, you can emulate the Firestore database locally, for example:
const admin = require("firebase-admin");
const test = require("firebase-functions-test")({
databaseURL: "http://localhost:8080",
projectId: "your-project-id",
});
const db = admin.firestore();
In this example, the local Firestore database is set up on port 8080. We can then perform any actions on the database, just as we would in the live environment.
Application examples for the Firebase Local Emulator
The Local Emulator Suite can be used in various ways:
- Unit testsFirebase Test SDK allows us to write unit tests in Node.js using the Mocha test runner. The Test SDK provides several handy methods for loading security rules, flushing the local database between tests, and managing synchronous interaction with the emulators. It's great for writing simple tests for database interactions that don't depend on the logic of our app.
- Integration testsEach individual product emulator in the Emulator Suite responds to SDK and REST API calls just like Firebase production services. So we can use our own testing tools to write standalone integration tests that use the Local Emulator Suite as a backend.
- Manual testsWe can connect our running application to the Local Emulator Suite to manually test our Firebase app without risking production data or configuring a test project.
- Product reviewsWe can install and manage Firebase extensions in a secure local environment and better understand our capabilities while minimizing billing costs.
Supported Firebase functions and platforms
The Firebase Local Emulator supports a variety of Firebase functions. These include
- FirestoreTest and develop with a locally emulated Firestore database.
- Realtime DatabaseEmulate Firebase's real-time database to simulate real-time data synchronization.
- Cloud Functions: Test cloud functions locally before we deploy them.
- Firebase AuthenticationSimulate authentication processes to ensure that security and authentication procedures work correctly.
- Cloud Pub/SubThis allows us to emulate the interactions between our services and test news publications and subscriptions.
- Firebase HostingCheck how our website or web app is hosted locally before we go live.
Conclusion
The Firebase Local Emulator is a powerful tool that is available to every Firebase developer. It offers security, speed and flexibility, which are essential for efficient and effective development. When we use Firebase in our projects, the use of the emulator is an absolute must.
Learn more about frontend development


