AN INTUITIVE NEW TOOL, FIREBASE

By Aaditi Kapre

If you’re a beginner , you might have thought of optimizing your site but are stuck in the confusing mess of JavaScript, React, SQL etc. luckily to our respite, Firebase by Google is to the rescue. Firebase is a tool-set to build, improve, and grow your app, and it gives a large portion of the services that developers would normally have to build themselves, but the knowledge required and effort is cumbersome. Firebase is essentially a back-end service, allowing the developers to focus primarily on the front-end or user experience. Its services are hosted in the cloud that means that the products have back-end components that are fully maintained and operated by Google. Firebase tools provided to the client interact with these back-end services directly, with no need to establish any middle-ware between your app and the service.

Features:

Firebase offers a wide variety of features such as user authentication, hosting website, real-time database and cloud storage, analytics, in-app messaging, making predictions and A/B testing(checking which user interface in the given options is liked by clients most). A beginner developer would normally have difficulty building these services on their own but with Firebase, a few simple clicks and commands enable you to have the best back-end services for your application. In this article I will try to introduce readers to some of these functions.

LETS TALK ABOUT HOSTING:

Firebase Hosting is web content hosting for developers. With a single command, you can quickly deploy web apps and serve both static and dynamic content to a global CDN (content delivery network). The main attraction of Firebase is that it hosts your website for free which eliminates the need of buying a custom domain. The free subdomains are of the type web.app and firebaseapp.com. You can host a single page app as well as a multi-filed app with equal ease as well as give your site a desired name with a few lines of additional code. You can also view and test your changes before deploying the site. Using the Firebase Local Emulator Suite, you can host your app and back-end resources at a locally hosted URL. You can also share your changes at a temporary preview URL and set up a GitHub integration.

To setup hosting in 3 simple steps visit this link: https://firebase.google.com/docs/hosting

WHAT IS THIS REALTIME FIREBASE DATABASE AND STORAGE?

Firebase enables you to remotely use Cloud Storage built for app developers who need to store and serve user-generated content, such as photos or videos. Cloud Storage for Firebase stores your files in a Google Cloud Storage bucket, making them accessible through both Firebase and Google Cloud .When using Google Firebase Storage, you can access files through references, easily upload files, and also monitor progress with tasks. Firebase storage aids in user-based data upload and download from the google cloud platform, and helps in verifying user identity and security of the data on your app.

The Realtime Database is a NoSQL database and as such has different optimizations and functionality compared to a relational database. The Realtime Database API (APIs are mediators between client requests and server) is designed to only allow operations that can be executed quickly. You can build a database for your app simply by going to your Firebase console, selecting your project and then going to database. As Firebase views data as JSON objects you don’t need to build the traditional tables requiring primary keys to connect them. Firebase just asks you for a name for the data, its type and a value to hold in it and voila! You can keep adding as much data you need in a similar easy fashion.

Now to connect this with your app, so that users can retrieve/add data you just need to copy paste a JavaScript code given by Firebase into your app, and then with simple commands such as GET — Reading Data ,PUT — Writing Data, POST — Pushing Data and PATCH — Updating Data you can build a dynamic website with user-server communication. Making a dynamic site that updates your Firebase database, these set of commands would be required and the codes for this are accessible on the net.

For detailed information: https://firebase.google.com/docs/database, https://firebase.google.com/docs/storage

HOW DOES AUTHENTICATION WORK FOR MY WEBSITE?

Most apps need to know the identity of a user. Knowing a user’s identity allows an app to securely save user data in the cloud and provide the same personalized experience across all of the user’s devices.

Firebase Authentication provides back-end services and ready-made UI libraries to authenticate users to your app. It supports authentication using passwords, phone numbers, popular federated identity providers like Google, Facebook and Twitter, and more.

Again, to apply this to your website, login to the Firebase console and select your project. Go to authentication in the build menu, there Firebase asks you for entering the permitted user’s data in the form of the authentication styles listed above. After this a mail/ SMS-text is sent to the user on their registered credentials and now the user has permission to access your website upon logging in.

After a successful sign in, you can access the user’s basic profile information, and you can control the user’s access to data stored in other Firebase products. You can also use the provided authentication token to verify the identity of users in your own back-end services. This feature of Firebase is free till a certain number of users but as your website scales-up some reasonable pricing is applicable.

For more information: https://firebase.google.com/docs/auth, https://www.toptal.com/firebase/role-based-firebase-authentication

MOVING ON TO THE RIGOROUS ANALYTICS :

Google Analytics for Firebase is a free app measurement solution that provides insight on app usage and user engagement. Analytics integrates across Firebase features and provides you with unlimited reporting for up to 500 distinct events that you can define using the Firebase toolkit. It automatically captures a number of events and user properties and also allows you to define your own custom events to measure the things that uniquely matter to your business. Once the data is captured, it’s available in a dashboard through the Firebase console. For example, some of the distinct events are: number of users on your site online, offline, per month, per day, number of hours spent by users on your site, number of crashes or failures, how much money did your site make, most popular features and their trends, page views per second, per minute, per hour, orders placed, sources of traffic, sources of revenues and many , many more features.

For detailed information : https://firebase.google.com/docs/analytics

SEEMS TOO IDEAL, ARE THERE NO CONS?

To list out the few cons of Firebase that don’t seem significant yet can’t be overlooked if you’re planning to expand your project:

Firebase focuses more on the Android devices since Android is commercially sponsored by Google. For iOS, the features in Firebase are minimum and inconvenient. Firebase has a paid version called Blaze plan. Blaze Plan is a ‘pay as you go’ option for apps at scale, there is no way of knowing in advance how the rise in traffic will impact the price in the end. The more your product goes, the more expensive Firebase becomes.

Next con is that Firebase uses Realtime Database as main storage and it doesn’t provide any filters to aid easy retrieval of data. It uses JSON file format, which makes your entire database a gigantic JSON file. Having database as a single file doesn’t allow introducing relations between different data files. As a result, you can’t query for more than one key at a time and querying for data becomes much more complicated in Firebase.

Adding to this, the more your product grows, the more issues you can have with data migration. If you want to shift your data from one place to another the zero SQL features in Firebase database, make it difficult to query the information you need to transfer it to another storage which is much easier in case of SQL tables.

In this era of data privacy supremacy, Firebase offers a limited set of security standards and rules and focuses on sharing data across platforms and users. If you do not intend to share your data with third party tools, do not consider Firebase as your back-end.

Concluding my attempt introduction to this fabulous tool created by Google, I recommend Firebase to all beginners who don’t have to worry about pricing or handling too many users and want an easy alternative to elaborate, time-consuming back-end. Configuring and practically using this can be daunting at first but it’s a brilliant tool to help developers build a state-of-the-art site with least possible efforts and is definitely worth checking out. For more guidance there are numerous videos and content by Firebase itself for each feature that will help you get started.

--

--

IEEE BITS PILANI KK Birla Goa Campus

We are the IEEE BITS Goa student chapter. We are committed to enhancing the technical culture on campus and beyond.