Firebase Cloud Functions

Cloud Functions

Firebase Cloud Functions are serverless offerering provided within Firebase ecosystem. With Cloud Functions you can completely abstract the underlying infrastructure and focus on your application. It’s a great tool for rapid prototype application develoment. As it’s under the Firebase ecosystem, it provides metrics and analytics for your cloud functions.

Firebase Cloud functions also seemlesslessly integrate with other Fireabse services and provide analytics for you Cloud Functions.

Getting Firebase Project Running

You can start by creating a Firebase project, using Web UI.

Setting up Node.js and Firebase CLI

As of current Cloud Functions only support Node.js. You also need to install Fireabse CLI to run your cloud function locally, deploy and test.


# Install Firebase Tools Package
npm install -g firebase-tools

# Login to Firebase Account
firebase login

# Project Setup
mkdir hello-cloud-functions
cd hello-cloud-functions

firebase init functions

# Make sure we have the latest for firebase-admin and firebase-functions
npm install firebase-admin@latest firebase-functions@latest

Select your Firebase project and select the defaults; And you are all set for your project. You can start writing your cloud functions.

exports.helloWorld = functions.https.onRequest((request, response) => {
 response.send("Hello from Firebase!");
});

The project gets shipped with the most basic form of Firebase Cloud Function implementation based on an HTTP Trigger.

Deploying your Function

## Deploy Firebase Function
firebase deploy

Now you have a working cloud function.

Resources