Send FCM notifications
This sample demonstrates how to send a Firebase Cloud Messaging (FCM) notification from a Realtime Database triggered Function when users get new followers. The sample also features a Web UI to experience the FCM notification.
Uses a Realtime Database trigger.
Google Assistant says ordinal of given number
This sample shows how to create an action for the Google Home/Assistant using the Actions SDK hosted on Cloud Functions. The sample action asks users to say a number and reads out the ordinal of that number.
Uses an HTTP trigger.
Authenticated JSON API
This sample shows how to authenticate access to a JSON API to only allow access to data for a specific Firebase user.
Uses an HTTP trigger.
Authorized HTTP endpoint
This sample shows how to restrict an HTTPS Function to only the Firebase users of your app.
Only users who pass a valid Firebase ID token as a Bearer token in the Authorization
header of the HTTP request or in a __session
cookie are authorized to use the function.
Checking the ID token is done with an ExpressJs middleware that also passes the decoded ID token in the Express request object.
Uses an HTTP trigger.
Authorize with 3rd-party authentication providers
Okta, LinkedIn, Spotify, Instagram, or Basic Auth
Demonstrates how to authorize with a 3rd party sign-in mechanism, create a Firebase custom auth token, update the user's profile and authorize Firebase.
Uses an HTTP trigger.
Post GitHub commits to Slack channel
Demonstrates how to automatically post GitHub commits to a Slack channel using an HTTPS triggered Function.
Create and charge customers with Stripe or Paypal
Demonstrates hows to integrate Firebase Auth and the Realtime database with Stripe via the Stripe Node.js library and shows how to create HTTP endpoints to charge customers via Paypal.
Text moderation
Demonstrates how to moderate user input text for bad words. This can be used to moderate usernames, chat or forum messages.
Uses a Realtime Database trigger.
Email confirmation
Sends email confirmation after users subscribed to a mailing list.
Uses a Realtime Database trigger.
Automatic message translation
Integrates the Google Translate API to perform automatic text translation across any number of languages. Language codes can be stored in Firebase for on the fly changes.
Uses a Realtime Database trigger.
Automatic URL shortener
Integrates the Bit.ly API to shorten URLs automatically as they are added to the database.
Uses a Realtime Database trigger.
Enable full-text search on Firebase Database data or Firestore documents by using a hosted search service.
Uses a Realtime Database or Firestore trigger.
User data cleanup
Deletes all associated user data in the Realtime database when a user deletes his Firebase account.
Uses an Auth trigger.
This code has moved to its own repo at
https://github.com/firebase/user-data-protection
Export your data to a Google Spreadsheet
This sample demonstrates how to sync new data written to a Firebase database to a Google Sheet. It includes a method for obtaining, storing, and using Oauth2 tokens for Google API access.
Uses HTTPS triggers and Realtime Database triggers.
Export your data to Big Query
Copies Firebase Database elements into BigQuery automatically. This can be useful for instance for further logs analysis.
Uses a Realtime Database trigger.
Webhook upon Firebase Database writes
Writing to the Firebase Database triggers a request to a callback URL (a Webhook). The content of the modified Data is sent to the Webhook.
Uses a Realtime Database trigger.
Send a survey when users update your app
This sample shows how to send a survey to your users who have updated your app. App Update is detected using a Firebase Analytics event.
Uses an Analytics trigger.
Send a coupon to user who have completed a purchase
This sample shows how to send a coupon to your users who have just purchased something. 10% off on your next purchase!
Uses an Analytics trigger.
Delete inactive users accounts via cron
Periodically deletes the accounts of users who have not signed in in the last month.
Uses an HTTPS trigger.
Developer Motivator
This sample demonstrates how to send a Firebase Cloud Messaging (FCM) notification to the developer device each time your app gains or loses a user.
Uses an Analytics trigger.
Audio Files Conversion
This sample uses ffmpeg / fluent-ffmpeg and automatically converts audio files that are uploaded to Cloud Storage to FLAC file format with mono-channel audio @ 16000hz.
Uses a Storage trigger.
Presence for Firestore
Build a simple online / offline status indicator for your users by leveraging Firestore and Realtime Database together.
Uses a Realtime Database trigger.
Publish Models to Firebase ML
Automatically publishes models to Firebase ML for each TensorFlow Lite file that is uploaded to Firebase Storage.
This sample shows how to query the Youtube Data API.
Uses an HTTPS trigger.