Google is committed to advancing racial equity for Black communities. See how.

Connect your app to the Cloud Functions Emulator

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

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);

HTTPS Functions

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

Background Triggered Functions

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?