functions-samples
Collection of sample apps showcasing popular use cases using Cloud Functions for Firebase
A collection of self-contained example projects for Cloud Functions for Firebase, showing how to run serverless code in response to file uploads, database writes, user sign-ups, scheduled timers, and web requests.
This repository is a collection of example projects for Cloud Functions for Firebase, published by Google. Cloud Functions is a service that lets you run small pieces of code on Google's servers in response to events, without setting up or managing your own server. Firebase is Google's platform for building mobile and web applications, and Cloud Functions connects to its various services.
The examples are organized by trigger type, which is the kind of event that causes a function to run. A trigger might be a user uploading a file to cloud storage, a document being written to a database, a new user account being created, an incoming web request, or a scheduled timer. Each sample shows a small, self-contained piece of code that responds to one of these triggers and does something useful with it.
The sample collection covers a wide range of practical use cases. Image processing examples show how to automatically generate thumbnails, convert image formats, or blur inappropriate content when a file is uploaded. Database examples show how to keep counts up to date, delete old records automatically, or keep data in sync across different parts of Firebase. Authentication examples show how to send welcome or farewell emails when users join or leave, or validate a user's email before allowing them to sign in. Other samples cover sending notifications to mobile devices, calling external APIs, using AI models to analyze text or images, and integrating with third-party services like Slack, PayPal, and Stripe.
Samples are available in both JavaScript (Node.js) and Python, and most support both the first and second generation of Cloud Functions. The README notes that Python support is currently in public preview, meaning it may still change. Deploying any of these samples requires a Firebase project with the Blaze pay-as-you-go billing plan enabled, as Cloud Functions does not run on the free tier when deployed to production.
This repository is intended as a learning and reference resource, not as a ready-to-deploy application. Each subdirectory contains its own README with setup and deployment instructions for that specific example.
Where it fits
- Automatically generate image thumbnails or blur inappropriate content whenever a user uploads a photo to Firebase Storage.
- Send a welcome email to a new user the moment they create an account via Firebase Authentication.
- Keep a running count or summary in your Firebase database that updates automatically when records are added or removed.
- Integrate a third-party service like Stripe or Slack into your Firebase app via a Cloud Function triggered by a database event.