Serverless Apps With Firebase Cloud Functions

Serverless Apps With Firebase Cloud Functions

Firebase’s goal is to help developers build better apps and grow them into successful businesses. By taking care of your app back-end or infrastructure, Firebase lets you focus on solving problems for your users. One of the new exciting features announced at the Google Cloud Next ’17 Conference this March for Firebase was Cloud Functions. In this tutorial, you’ll learn about this new feature by building a simple Android app with it.

What Are Cloud Functions for Firebase?

Firebase Cloud Functions run in a hosted, private, and scalable Node.js environment where you can run JavaScript code. You simply create reactive functions that trigger whenever an event occurs. Cloud functions are available for both Google Cloud Platform and Firebase (they were built on top of Google Cloud Functions).

For now, Cloud Functions support the following triggers that you can listen to and respond to:

So Why Use Cloud Functions?

So now you have seen the range of capabilities that Cloud Functions can offer. But why use them?

Running and setting up a back end and servers can be a real pain—you have to handle issues such as scalability and writing code in server-side languages—but with Cloud Functions, this complexity is reduced. Also, computationally intensive tasks can be performed in the cloud instead of on the client device (such as image resizing for upload or writing to multiple paths of your database). Your code will also be more secure in the cloud than on the client device, so you can securely store data such as secret keys on your server.

In this tutorial, you’ll learn how to use the Realtime Database Triggers that will fire when a database write event occurs. Then, we’ll see how to use the Firebase Cloud Messaging service to send a notification to devices that subscribed to a topic. We’ll create a simple app called Tutsplus Alerts, which will send a notification to subscribers of the “android” topic whenever a new article is available.

Continue to read the full article on Tuts+.