Before connecting your app to the Cloud Functions emulator, make sure that you understand the overall Firebase Local Emulator Suite workflow and that you install and configure the Local Emulator Suite.
Instrument your app to talk to the emulators
Instrument your app for callable functions
If your prototype and test activities involve callable backend functions, configure interaction with the Cloud Functions for Firebase emulator like this:
Android
// 10.0.2.2 is the special IP address to connect to the 'localhost' of // the host computer from an Android emulator. FirebaseFunctions functions = FirebaseFunctions.getInstance(); functions.useEmulator("10.0.2.2.", 5001);
iOS - Swift
Functions.functions().useFunctionsEmulator(origin: "http://localhost:5001")
Web
firebase.functions().useEmulator("localhost", 5001);
Instrument your app for HTTPS functions emulation
Each HTTPS function in your code will be served from the local emulator using the following URL format:
http://$HOST:$PORT/$PROJECT/$REGION/$NAME
For example a simple helloWorld
function with the default host port and region would be served at:
https://localhost:5001/$PROJECT/us-central1/helloWorld
Instrument your app for background-triggered functions emulation
The Cloud Functions emulator supports background-triggered functions from the following sources:
- Realtime Database emulator
- Cloud Firestore emulator
- Authentication emulator
- Cloud Pub/Sub emulator
To trigger background events, connect your app or test code to the emulators using the SDK for your platform.
What next?
- For a curated set of videos and detailed how-to examples, follow the Firebase Emulators Training Playlist.
- Learn more about the Cloud Functions for Firebase emulator at Run functions locally.