What is the difference between Cloud Functions and Firebase Functions?

FirebaseGoogle Cloud-PlatformGoogle Cloud-Functions

Firebase Problem Overview


Cloud Functions and Firebase Functions (or "Cloud Functions for Firebase") both look the same. Please describe the use case of each.

Both use HTTP functions.

In the Cloud Functions:

exports.helloHttp = function helloHttp (req, res) {
  res.send(`Hello ${req.body.name || 'World'}!`);
};

And in the Firebase Functions:

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

What is difference between these?

Firebase Solutions


Solution 1 - Firebase

There is no product called Firebase Functions.

There are three separate things:

  1. Google Cloud Functions, which allow you to run snippets of code in Google's infrastructure in response to events.
  2. Cloud Functions for Firebase, which triggers Google Cloud Functions based on events in Firebase (such as database or file writes, user creation, etc)
  3. Firebase SDK for Cloud Functions, which includes a library (confusingly called firebase-functions) that you use in your Functions code to access Firebase data (such as the snapshot of the data that was written to the database)

So Firebase provides a (relatively thin) wrapper around Google Cloud Functions, to make the latter product easier to use and integrate it with Firebase. In that senses it is similar to how Firebase integrates Google Cloud Storage into "Cloud Storage for Firebase" (formerly known as Firebase Storage).

If you're using Google Cloud Platform without Firebase, then you should use plain Google Cloud Functions. If you're on Firebase or if you're a mobile developer interested in Cloud Functions, you should use Cloud Functions for Firebase.

Solution 2 - Firebase

There is an additional difference: Firebase Functions can only be implemented in JS or Node.JS, while Cloud Functions also allow the use of Python and Go.

There is also a small difference in terms of how they are priced, if you are on the Spark Plan. Check this out https://firebase.google.com/pricing vs. https://cloud.google.com/functions/pricing if you are on the Blaze plan, the pricing is the same.

I happen to use both for my Firebase project.

Solution 3 - Firebase

Google Cloud Platform, GCP, has an article addressing this question, Google Cloud Functions and Firebase.

> ### Google Cloud Functions and Firebase > > Google Cloud Functions is Google's serverless compute solution for > creating event-driven applications. It is a joint product between the > Google Cloud Platform team and the Firebase team. > > For Google Cloud Platform developers, Cloud > Functions serve as a connective > layer allowing you to weave logic between Google Cloud Platform (GCP) > services by listening for and responding to events. > > For Firebase developers, Cloud Functions for > Firebase provides a way > to extend the behavior of Firebase and integrate Firebase features > through the addition of server-side code. > > Both solutions provide fast and reliable execution of functions in a > fully managed environment where there's no need for you to worry about > managing any servers or provisioning any infrastructure. > > ... > > Cloud Functions for Firebase is optimized for Firebase developers: > > - Firebase SDK to configure your functions through code > - Integrated with Firebase Console and Firebase CLI > - The same triggers as Google Cloud Functions, plus Firebase Realtime Database, Firebase Authentication, and Firebase Analytics triggers

Solution 4 - Firebase

Official Google Video Describing the difference: GCP vs. Firebase - Functions & Firestore

  1. Firebase will offer you to wrap your functions into callable functions which can be invoked via firebase SDK
  2. language support, GCP also supports Go, Python and java
  3. GCP could be deployed both via console or CLI, but firebase functions only via CLI

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionMuhammad chhotaView Question on Stackoverflow
Solution 1 - FirebaseFrank van PuffelenView Answer on Stackoverflow
Solution 2 - FirebaseAlexei MasterovView Answer on Stackoverflow
Solution 3 - FirebaseRonnie RoystonView Answer on Stackoverflow
Solution 4 - FirebaseAli80View Answer on Stackoverflow