Creating Firebase Cloud Functions

Scenario: You want to create custom serverless functions for your trackjs/javascript-gameshow project using Firebase Cloud Functions. Follow the official documentation on creating Firebase Cloud Functions at

Codebase Files and Directories:

  • audience-app/
    • ...
  • presenter-app/
    • ...


  1. This blog post provides a comprehensive introduction to Firebase and its features. It covers setting up a Firebase app, choosing features, and connecting to the Cloud Firestore database.
  2. This document explains the OpenTelemetry semantic conventions for Function as a Service (FaaS) resources. It covers the function, function version, function name, and other relevant attributes.
  3. This blog post discusses the benefits of using Firebase for various use cases, including serverless functions.
  4. This article compares Heroku with Firebase as alternatives for deploying web apps and mentions Firebase's support for serverless functions.
  5. This plugin enables integrating data on Firestore into Grafana dashboards.
  6. This blog post explains how to get started with Firebase, including creating a Firebase account, creating a Firebase app, and setting up authentication and the Realtime Database/Cloud Firestore.
  7. This article compares AWS Lambda, Azure Functions, and Google Cloud Functions, including their trigger types.
  8. This blog post discusses Firebase Cloud Messaging (FCM) and its benefits, such as easy and reliable authentication and sending messages to targeted groups.
  9. This documentation provides information on deploying a Cloud Function to Google Cloud Platform using Terraform.

Steps to Create Firebase Cloud Functions:

  1. Install Firebase CLI:

    npm install -g firebase-tools
  2. Initialize Firebase in your project:

    firebase init functions

    Follow the prompts to set up the Firebase Cloud Functions project.

  3. Create a new function:

    firebase function:add <function_name>

    Replace <function_name> with the desired name for your function.

  4. Write the function code in the functions/<function_name>/index.js file.

  5. Configure the function:

    • Update the functions/<function_name>/package.json file with any required dependencies.
    • Update the functions/<function_name>/functions.js file with the exported function name.
    • Update the functions/<function_name>/index.ts file (if using TypeScript) with the function code and exports.
  6. Deploy the function:

    firebase deploy --only functions


  1. Create a test file in the functions/<function_name>/__tests__/ directory with a name ending in .test.js or .ts.
  2. Write tests for your function using the Firebase Testing Library (firebase-functions-testing).
  3. Run the tests:
    npm run test

Additional Resources: