firebase/functions-samples
35.2
Weak · 30 October 2026
12k
lines of production code
JavaScript
with Python
4
measurements over time
What this system is
This repository serves as a comprehensive collection of reference implementations and quickstart samples for Firebase Cloud Functions, supporting Node.js, Python, and Dart. It demonstrates modern 2nd-generation architecture patterns, including event-driven triggers, callable functions, streaming responses, and task queues across various Firebase services like Firestore, Realtime Database, and Cloud Storage. The codebase also provides practical examples for integrating external AI models via Vertex AI, managing authentication contexts, and implementing robust testing workflows with Jest and Mocha.
How it got here
2018–2023 — Migration to 2nd Gen and SDK Modernization
22 changes.
This period focused on migrating Node.js and Python samples to the Firebase Cloud Functions 2nd generation architecture, introducing codebase-based deployment and modular SDK imports. The work also involved updating dependencies to newer Node.js and Firebase SDK versions, adding new samples for testing, observability, and specific integrations, and refining existing functions for better compatibility and security.
2024–2026 — AI integration and Dart SDK expansion
11 changes.
This period focused on expanding Firebase Cloud Functions capabilities by integrating Vertex AI Gemini models with Remote Config and adding comprehensive streaming support for callable functions. It also marked the introduction of official Dart quickstarts and codelabs, alongside new samples for Firestore sync with authentication and YouTube API integration.
Features
Add 2nd-gen YouTube sample function
Added a new Firebase Cloud Functions (2nd Gen) sample that queries the YouTube Data API v3 to retrieve channel information and recent videos. The sample uses an HTTPS callable trigger, requires the YouTube API via declarative configuration, and utilizes a secret for the API key.
Node/youtube · high confidence
Add Dart codelab sample for Firebase Functions
This change introduces a new codelab sample demonstrating how to build a Flutter client that interacts with Dart functions deployed on Firebase. The sample includes a shared package containing the \IncrementResponse\ model (with JSON serialization) to ensure type consistency between the client and server, and a Flutter UI (\CounterPage\) that calls the remote function to display a multiplayer counter.
Dart/codelab-dart-functions, Dart/codelab-dart-functions/packages/shared · high confidence
Add Firestore sync with auth quickstart sample
Added a new Node.js quickstart sample demonstrating how to use the Firebase SDK for Cloud Functions with Firestore while preserving authentication context. The sample includes configuration files for the Firebase Emulator Suite, Firestore security rules that restrict read/write access to authenticated users, and documentation on running and deploying the function.
Node/quickstarts/firestore-sync-auth · high confidence
Add Genkit streaming joke-teller function sample
The functions directory now includes a new \index.js\ sample that demonstrates how to use \onCallGenkit\ to expose a Genkit flow as a Firebase callable function. This sample defines a \jokeTeller\ flow using the Gemini 1.5 Flash model, implements streaming support by sending chunks via \sendChunk\, and binds the Gemini API key from Cloud Secret Manager. The entry also adds a \.gitignore\ to exclude \node\_modules\ and an \eslint.config.js\ to relax linting rules for the sample code.
Node/quickstarts/genkit-helloworld/functions · high confidence
Add Node.js 1st-gen sample codebases
This change introduces the source code for several Node.js 1st-gen Cloud Functions samples, including authenticated JSON APIs, authorized HTTPS endpoints, BigQuery imports, and image conversion. Each sample provides a complete project structure with function code, hosting UI, and configuration files to demonstrate specific Firebase integrations.
Node-1st-gen · high confidence
Add generateWithVertex sample function for Vertex AI integration
A new \generateWithVertex\ HTTPS function has been added to the remote config server sample. This function allows users to query Vertex AI Gemini models (defaulting to \gemini-1.5-flash-002\) using prompts and configuration settings managed via Firebase Remote Config. It supports streaming responses, configurable safety settings, and requires specific IAM roles (\roles/aiplatform.user\, \roles/cloudconfig.viewer\) and APIs (\aiplatform.googleapis.com\, \firebaseremoteconfig.googleapis.com\) to operate.
Node/remote-config-server-with-vertex/functions · high confidence
Add streaming callable functions quickstart
A new quickstart sample demonstrates how to use Firebase Cloud Functions to stream responses to client SDKs. The sample includes a callable function that fetches weather forecasts and sends them incrementally using \response.sendChunk()\, paired with a web interface that utilizes the \httpsCallable().stream()\ API to update the UI in real-time as each forecast chunk arrives.
Node/quickstarts/callable-functions-streaming · high confidence
Add web client for calling Vertex AI with Remote Config and App Check
A new web client application has been added to demonstrate calling the \callVertexWithRC\ Cloud Function. This client initializes Firebase and App Check (using ReCAPTCHA Enterprise), sends user prompts to the backend function, and renders the Gemini API response as HTML using the Marked library. It includes configuration placeholders for Firebase and ReCAPTCHA keys, supports local emulator testing via Vite, and provides a simple UI with loading indicators and error handling.
Node/call-vertex-remote-config-server/client · high confidence
Added 2nd-gen Cloud Functions quickstart with Mocha testing
A new sample project has been added to demonstrate how to write and run unit tests for 2nd-generation Cloud Functions using Mocha. The sample includes a storage trigger function that logs events, along with a corresponding test file that uses \firebase-functions-test\ to verify the function's behavior.
Node/test-functions-mocha · high confidence
Added Firebase Storage function and tests for logging object finalization
A new Firebase Cloud Function named \logstore\ has been added to the \Node/test-functions-jest-ts/functions\ sample. This function triggers on the \onObjectFinalized\ event for a specified storage bucket and logs the incoming CloudEvent. A corresponding Jest test file has also been added to verify that the function correctly invokes the logger for both default and partial CloudEvent inputs.
Node/test-functions-jest-ts/functions · high confidence
Added Node.js quickstart for testing Gen-2 Firebase Functions with Jest
This location introduces a new sample demonstrating how to unit test Google Cloud Functions for Firebase (Gen-2) using Jest. It includes a storage-triggered function (\onObjectFinalized\) and a corresponding test suite that utilizes \firebase-functions-test\ to wrap and verify the function's behavior, alongside standard configuration files like \firebase.json\ and ESLint rules.
Node/test-functions-jest · high confidence
Added TypeScript and Jest testing quickstart for Gen-2 Functions
This location introduces a new sample project demonstrating how to run unit tests on Gen-2 Cloud Functions using Jest and TypeScript. The addition includes configuration files for the testing environment (jest.config.js, tsconfig.json), linting setup (eslint.config.js), and Firebase project settings (firebase.json) to support a standard development workflow for this specific testing pattern.
Node/test-functions-jest-ts · high confidence
New 2nd Gen Node.js quickstart samples with codebase support
Added new Node.js quickstart samples for custom events, cloud logging, Pub/Sub, Test Lab, Firestore, and Realtime Database. These samples use the 2nd generation Cloud Functions SDK (e.g., \onCustomEventPublished\, \onMessagePublished\, \onDocumentCreated\) and are configured with distinct \codebase\ entries in \firebase.json\ to support the new codebase-based deployment model.
(repo-wide) · high confidence
New 2nd-gen email quickstart with multi-tenancy support
Added a new Node.js quickstart demonstrating 2nd-generation Firebase Auth-triggered Cloud Functions that send welcome and farewell emails via Resend. The sample includes functions for new user creation and account deletion, plus multi-tenancy examples that scope triggers to specific Identity Platform tenants or exclude them entirely, and provides updated local development instructions for the Firebase Emulator Suite.
Node/quickstarts/email-users · high confidence
New Dart quickstarts for Firebase Cloud Functions
Added Dart sample projects for Firebase Cloud Functions, including a codelab for deploying Dart functions and quickstarts demonstrating HTTPS triggers (date server, image resizing), callable functions (add numbers), and callable functions with streaming responses (weather forecast). These samples provide reference implementations for common server-side patterns using the Dart SDK.
Dart · high confidence
New FCM follower notification function with token cleanup
A new Cloud Function, sendFollowerNotification, has been added to handle real-time follower notifications. Triggered by changes in the Realtime Database, it sends push notifications to users when they gain a new follower and includes logic to automatically remove invalid or unregistered FCM tokens from the database to maintain list hygiene. The implementation also includes standard project configuration files (.gitignore and eslint.config.js) to support the new code.
Node/fcm-notifications/functions · high confidence
New Firebase 2nd Gen sample for sending in-app feedback to Jira
Adds a new sample application that triggers a Firebase Cloud Function when an in-app feedback alert is published via Firebase App Distribution, creating a corresponding issue in Jira with the feedback text and attached screenshot. The implementation uses the Firebase 2nd Gen functions API (importing from firebase-functions/alerts/appDistribution), leverages parameterized configuration for Jira connection details (URI, project key, issue type, labels, and API token owner), and stores the Jira API token securely in Google Cloud Secret Manager.
Node/app-distribution-feedback-to-jira · high confidence
New Firestore security rule function to verify user identity
Added a new Cloud Function in the Firestore sync auth quickstart that automatically marks user accounts as verified based on their authentication context. The function triggers on document writes to the 'comments' collection and sets a 'verified' flag to true for system-generated users or admin users from the '@example.com' domain, while leaving other users unverified. It also records the creator's ID in the document metadata.
Node/quickstarts/firestore-sync-auth/functions · high confidence
New callable function to integrate Vertex AI Gemini with Firebase Remote Config
Added a new callable Cloud Function (\callVertexWithRC\) that allows users to dynamically configure and invoke Google Cloud Vertex AI Gemini models using Firebase Remote Config. The function retrieves model parameters (such as model name, prompt, generation config, safety settings, and region) from a Remote Config server template, enabling runtime updates without redeployment. It enforces App Check, requires specific IAM roles (\roles/aiplatform.user\, \roles/cloudconfig.viewer\) and APIs (\aiplatform.googleapis.com\, \firebaseremoteconfig.googleapis.com\), and streams the generated content back to the client.
Node/call-vertex-remote-config-server/functions · high confidence
New sample for instrumenting Firebase Cloud Functions with OpenTelemetry
Added a new sample demonstrating how to instrument Cloud Functions for Firebase using OpenTelemetry to export traces to Google Cloud Trace. The sample includes a callable function that uses the OpenTelemetry API to create custom spans for price and discount calculations, alongside automatic instrumentation for HTTP, gRPC, and Express modules via a preloaded tracing module. It also configures the necessary IAM roles and APIs for trace export and sets up the Firebase project with a specific codebase and emulator settings.
Node/instrument-with-opentelemetry · high confidence
Behavioural changes
Callable functions quickstart updated to use v2 SDK and new sanitization logic
The callable functions quickstart has been updated to use the v2 \firebase-functions/https\ SDK, replacing the previous v1 imports. The \addmessage\ function now explicitly checks for user authentication via \request.auth\ before saving messages to the Realtime Database. Additionally, the text sanitization logic in \sanitizer.js\ has been modified to remove the previous behavior of auto-capitalizing sentences when users 'shout', while retaining the filtering of swearwords using the \bad-words\ library.
Node/quickstarts/callable-functions/functions · high confidence
HTTPS time-server quickstart updated to Firebase Functions v2
The HTTPS time-server quickstart has been migrated to the Firebase Functions v2 SDK, replacing the previous v1 imports with the \firebase-functions/https\ module. This change introduces support for specifying multiple deployment regions (us-west1, us-east1) and increases the default timeout to 1200 seconds. The sample function now returns the current server date, accepting a date format string via URL query parameters or the request body, while explicitly rejecting PUT requests with a 403 error. Configuration files for the Firebase CLI and ESLint have also been added to support this 2nd-gen architecture.
Node/quickstarts/https-time-server · high confidence
Image backup function migrated to Firebase Functions v2 with task queues
The Node.js function in this directory has been updated to use the Firebase Functions v2 runtime, replacing the previous v1 imports with the new \firebase-functions/tasks\ and \firebase-functions/https\ modules. This change introduces support for task queues, allowing the \backupapod\ function to be dispatched asynchronously with configurable retry policies and rate limits, while the \enqueuebackuptasks\ function now schedules these tasks using the v2 API. The implementation also switches HTTP client usage from external libraries to the native \fetch\ API and includes a new ESLint configuration to relax strict linting rules for this snippet.
Node/taskqueues-backup-images/functions · high confidence
Python samples migrated to 2nd generation Cloud Functions
The Python samples have been updated to use the 2nd generation Cloud Functions for Firebase SDK. This introduces a new API surface, including dedicated trigger modules for alerts (Crashlytics, App Distribution, Performance), database, HTTP, and scheduled events, as well as support for auth blocking functions and task queues. The samples now utilize the \firebase\_functions\ package and are organized into distinct codebases, requiring an update to existing Python function code to align with the new generation's structure and capabilities.
Python · high confidence
Remote Config diff function migrated to 2nd-gen architecture
The \showconfigdiff\ Cloud Function has been updated to use the 2nd-generation Firebase Functions runtime (\firebase-functions/remoteConfig\). This change replaces the previous HTTP-triggered implementation with a declarative \onConfigUpdated\ trigger, automatically handling Remote Config versioning to compare current and previous templates. The function now explicitly declares required IAM roles (\roles/cloudconfig.viewer\) and APIs (\firebaseremoteconfig.googleapis.com\) using \requiresRole\ and \requiresAPI\, and utilizes native Node.js \fetch\ instead of external libraries like axios or node-fetch for API calls.
Node/remote-config-diff/functions · high confidence
Sample updated to use Firebase Functions 2nd gen and Cloud Scheduler
The delete-unused-accounts-cron sample has been migrated to the 2nd generation of Firebase Cloud Functions. It now uses the \firebase-functions/scheduler\ API with \onSchedule\ to trigger the account cleanup job daily at midnight, replacing the previous implementation. The configuration includes a \firebase.json\ file defining a specific codebase for the function, and the code utilizes the Firebase Admin SDK to list and delete inactive users with controlled concurrency.
Node/delete-unused-accounts-cron · high confidence
Updated Cloud Storage trigger quickstart to use v2 SDK
The thumbnails quickstart has been updated to use the Firebase Functions v2 SDK, replacing the previous v1 imports with the new \onObjectFinalized\ trigger. This change modernizes the sample code to align with current best practices for Cloud Storage triggers, ensuring users following this guide implement functions using the latest, more efficient event model.
Node/quickstarts/thumbnails · high confidence
Updated FCM notifications sample to use Firebase Functions v2 and modern SDKs
The FCM notifications sample has been updated to use the Firebase Functions v2 API (specifically \onValueWritten\) and the modular Firebase Admin SDK, replacing the older v1 syntax. The web client now uses Firebase SDK version 10.0.0, and the project includes updated configuration files (firebase.json, database.rules.json) and a new ESLint configuration to support the modern codebase. Also in this area: Updated Firebase SDK version to 13.1.0 and corrected function names in documentation; Firebase SDK updated to version 13.0.0 in Node and Python quickstarts; Declarative API and IAM requirements and region updates in Node samples.
Node/fcm-notifications/public · high confidence
Updated Firebase Cloud Functions samples to 2nd-gen architecture
The alerts-to-discord and testlab-to-slack samples have been migrated to Firebase Cloud Functions 2nd generation. This update replaces the previous v1 imports with the new v2 alert and test lab triggers, switches HTTP client usage from axios/node-fetch to the native fetch API, and configures the functions to use the new codebase-based deployment structure defined in firebase.json.
Node/alerts-to-discord, Node/testlab-to-slack · high confidence
Updated Firestore quickstart to use modular Firebase SDK imports
The Node quickstart sample has been updated to use the modern, modular import syntax for the Firebase SDKs. Instead of the legacy \firebase-functions\ package, the code now imports specific triggers like \onRequest\ and \onDocumentCreated\ directly from \firebase-functions/https\ and \firebase-functions/firestore\, and initializes the Admin SDK using \firebase-admin/app\. This change aligns the sample with current best practices for tree-shaking and modular architecture in Cloud Functions.
Node/quickstarts/uppercase-firestore · high confidence
Updated auth-blocking-functions quickstart to Firebase Functions 2nd Gen
The auth-blocking-functions sample has been migrated to Firebase Cloud Functions 2nd Gen, updating the implementation to use the \firebase-functions/identity\ API for blocking account creation, sign-in, email sending, and SMS sending. The sample now includes a \firebase.json\ configuration with a dedicated codebase and enforces linting via ESLint before deployment, ensuring the code follows modern standards for Firebase Auth extension points.
Node/quickstarts/auth-blocking-functions · high confidence
Vision annotate function now accepts JSON string or object input
The \annotateImage\ callable function in the Vision sample now accepts the request payload as either a JSON string or a JavaScript object. Previously, the implementation likely expected a specific format, but the updated code explicitly checks the type of the incoming \data\ argument and parses it via \JSON.parse\ if it is a string, ensuring compatibility with both Android (which sends a JSON string) and Apple (which sends an object) client snippets.
Node-1st-gen/vision-annotate-images/functions · high confidence
Dependencies
Update Node.js samples to Firebase Functions v7 and Node 22
The Node.js 1st-generation sample functions have been updated to use \firebase-functions\ version 7.3.2 and \firebase-admin\ version 14.2.0, with the runtime engine set to Node 22. Additionally, Dart quickstart samples for callable and HTTPS functions have been added, utilizing the \firebase\_functions\ SDK version 0.6.0 and Dart SDK 3.11.0.
(dependencies) · high confidence
Written by watchdog.canine.dev from the codebase's own history, inside the signed delivery this page is composed from.
How this codebase got here
Score
- CAI 38 → 35 (-2.7)
Lenses
- Code Health 80 → 80 (+0.0)
- Architecture 100 → 100 (+0.0)
- Maturity 58 → 39 (-18.6)
- Readiness 22 → 22 (+0.0)
- Security 57 → 56 (-1.2)
- Accessibility 33 → 33 (+0.0)
- Performance 100 → 100 (+0.0)
Resolved (9)
- High CVE: [GHSA redacted] (Node/quickstarts/genkit-helloworld/functions/pnpm-lock.yaml)
- High CVE: [GHSA redacted] (Node/quickstarts/genkit-helloworld/functions/pnpm-lock.yaml)
- High CVE: [GHSA redacted] (Node-1st-gen/fulltext-search-firestore/functions/pnpm-lock.yaml)
- High CVE: [GHSA redacted] (Node-1st-gen/okta-auth/functions/pnpm-lock.yaml)
- Medium CVE: [GHSA redacted] (Node/quickstarts/genkit-helloworld/functions/pnpm-lock.yaml)
- Medium CVE: [GHSA redacted] (Node-1st-gen/okta-auth/functions/pnpm-lock.yaml)
- Medium CVE: [GHSA redacted] (Node-1st-gen/okta-auth/functions/pnpm-lock.yaml)
- Medium CVE: [GHSA redacted] (Node/app-distribution-feedback-to-jira/functions/pnpm-lock.yaml)
- Off-boarding risk: anonymized user #1
New (794)
- Critical CVE: [GHSA redacted] (Node/quickstarts/genkit-helloworld/functions/pnpm-lock.yaml)
- Critical CVE: [GHSA redacted] (pnpm-lock.yaml)
- Critical CVE: [GHSA redacted] (Node-1st-gen/authorized-https-endpoint/functions/pnpm-lock.yaml)
- Critical CVE: [GHSA redacted] (Node-1st-gen/bigquery-import/functions/pnpm-lock.yaml)
- Critical CVE: [GHSA redacted] (Node-1st-gen/child-count/functions/pnpm-lock.yaml)
- Critical CVE: [GHSA redacted] (Node-1st-gen/convert-images/functions/pnpm-lock.yaml)
- Critical CVE: [GHSA redacted] (Node-1st-gen/coupon-on-purchase/functions/pnpm-lock.yaml)
- Critical CVE: [GHSA redacted] (Node-1st-gen/delete-old-child-nodes/functions/pnpm-lock.yaml)
- Critical CVE: [GHSA redacted] (Node-1st-gen/delete-unused-accounts-cron/functions/pnpm-lock.yaml)
- Critical CVE: [GHSA redacted] (Node-1st-gen/developer-motivator/functions/pnpm-lock.yaml)
- Critical CVE: [GHSA redacted] (Node-1st-gen/email-confirmation/functions/pnpm-lock.yaml)
- Critical CVE: [GHSA redacted] (Node-1st-gen/exif-images/functions/pnpm-lock.yaml)
- Critical CVE: [GHSA redacted] (Node-1st-gen/fcm-notifications/functions/pnpm-lock.yaml)
- Critical CVE: [GHSA redacted] (Node-1st-gen/ffmpeg-convert-audio/functions/pnpm-lock.yaml)
- Critical CVE: [GHSA redacted] (Node-1st-gen/fulltext-search-firestore/functions/pnpm-lock.yaml)
- Critical CVE: [GHSA redacted] (Node-1st-gen/fulltext-search/functions/pnpm-lock.yaml)
- Critical CVE: [GHSA redacted] (Node-1st-gen/github-to-slack/functions/pnpm-lock.yaml)
- Critical CVE: [GHSA redacted] (Node-1st-gen/google-sheet-sync/functions/pnpm-lock.yaml)
- Critical CVE: [GHSA redacted] (Node-1st-gen/image-maker/functions/pnpm-lock.yaml)
- Critical CVE: [GHSA redacted] (Node-1st-gen/lastmodified-tracking/functions/pnpm-lock.yaml)
- …and 774 more
Changes since last survey
- 2 commits — 2 feature/other, 0 fixes
By area
- Node-1st-gen/linkedin-auth — 1 commit
- Node/quickstarts — 1 commit
Notable commits
- change: Auto-update dependencies. (#1367)
- change: docs(email-users): fix README file and function names (#1368)
Written by watchdog.canine.dev from the codebase's own history, inside the signed delivery this page is composed from.
Survey your own repository
firebase/functions-samples was measured the same way every project in this corpus was: the same rubric, at a pinned commit, with the result published in full. Point a surveyor at a repository you know and see whether you agree with it.
About this page
- The score is its most recent published measurement, taken on 30 October 2026 at a pinned commit. It is not a live figure and does not change until the project is measured again.
- Measured at commit 5c5ef9a5ad4faa16215c7a406d1afe3f8c3b9c32 — the exact code this score is about.
- Scored under rubric-2026.10.5 — the same rubric and the same method as every other entry in this index.
- Measured by watchdog.canine.dev using codehealth-analyzer measure-2026.10.41+preprod-baf33b0affda.