Debug Functions locally

turn on functions in the emulator

We run the functions on their own or with other emulators.

npm run serve
firebase emulators:start --only functions

firebase emulators:start --import emulator-data --export-on-exit

invoke emulated functions from a CLI shell

The shell command also starts an interactive CLI shell from which we can invoke Callable functions with data arguments.

The command starts the emulator and connects a CLI REPL shell session to it so that we may trigger the functions from the CLI:

firebase functions:shell
npm run shell # alternative

call a Callable function from the CLI: we add the request's payload to the mandatory data property.

requestArticles({ data: { name: "Lena" } })

invoke emulated functions from the client SDK

We redirect invocations towards the emulated functions, but only on localhost:

if (location.hostname === "localhost") {
    // ...
    connectFunctionsEmulator(functions, "localhost", 5001)
}

make direct HTTP requests to non-Callable functions

The HTTP functions' URL follows a specific pattern:

<HOST>/<PROJECT-ID>/<REGION>/<FUNC_NAME>
http://localhost:5001/imgtale/europe-west1/request_articles
curl -s -H "Content-Type: application/json" \
  -d '{ "data": { } }' \
  http://localhost:5001/imgtale/europe-west1/request_articles
earlymorning logo

© Antoine Weber 2026 - All rights reserved

Debug Functions locally

turn on functions in the emulator

We run the functions on their own or with other emulators.

npm run serve
firebase emulators:start --only functions

firebase emulators:start --import emulator-data --export-on-exit

invoke emulated functions from a CLI shell

The shell command also starts an interactive CLI shell from which we can invoke Callable functions with data arguments.

The command starts the emulator and connects a CLI REPL shell session to it so that we may trigger the functions from the CLI:

firebase functions:shell
npm run shell # alternative

call a Callable function from the CLI: we add the request's payload to the mandatory data property.

requestArticles({ data: { name: "Lena" } })

invoke emulated functions from the client SDK

We redirect invocations towards the emulated functions, but only on localhost:

if (location.hostname === "localhost") {
    // ...
    connectFunctionsEmulator(functions, "localhost", 5001)
}

make direct HTTP requests to non-Callable functions

The HTTP functions' URL follows a specific pattern:

<HOST>/<PROJECT-ID>/<REGION>/<FUNC_NAME>
http://localhost:5001/imgtale/europe-west1/request_articles
curl -s -H "Content-Type: application/json" \
  -d '{ "data": { } }' \
  http://localhost:5001/imgtale/europe-west1/request_articles