In this post, we will talk about why you should use Firebase as your backend. So what is Firebase? I bet some of you guys have never heard of it (I didn’t mean to hurt the informed part of the readers, my apologies). Anyway, today each and everyone is going to learn something new. Because right now, we will be overviewing Firebase and its services to finally find out how it can help you out with building your product.
What Exactly is a backend?
Typically, a backend has a server, some applications running on that server and a database. If you are creating an app and want to have a backend with it, then you will need to configure all of the backend components yourself. This can be a lot difficult if you are a freelancer or a small team of developers. The backend not only has to work with your app, but needs to scale as your app grows. And not to mention all the crashes and bugs that you will have to figure out. Also, if you are storing any data on your backend, you usually would become a target for hackers, now you have to figure out the security for your app.
History of Firebase
So What is Firebase? Firebase was founded by Andrew Lee and James Tamplin in 2011 and launched officially in April 2012. Originally, the system was intended to be a real-time database providing its APIs enabling users to store and sync data across different clients. However, the plans changed a little bit when Firebase was acquired by Google two years later after its release. Today, the Firebase service has a number of functions that really attract every developer.
Firebase is free up to a limit the there some pricing options that you can read about here. The thing I love about the pricing is that free apps are not free based on time but based on traffic. Which is great for apps that are starting out, you can create an app on firebase for free and only pay when your app gets past certain traffic threshold.
There are usually two ways: you either want to develop a completely Firebase-powered application or resort to some of the service features to create a partially powered one. Now I’ll try to explain what it actually means
A completely Firebase-powered application
The thing is, your future app may consist of a client code only. In this case, all you need is Firebase and its ability to distribute your product. If the description of your application matches one of the following, then Firebase should be your #1 choice:
- Your app is not about heavy data processing and doesn’t have any complex user authentication needs.
- Your app doesn’t need the integration with any third-party systems (payment gateway, GPS, log-in via social networks, etc.) and legacy systems (gross, outdated ones).
- You are trying to create a new application (not complex!) or give the second chance to an existing one by rewriting its code.
What happens is that the dynamic content of your application and user data are stored and retrieved from Firebase. The static content of your app is packaged up into the client-side code. So here comes the first feature which makes all of the abovesaid possible.
1- Firebase Auth
What about non-complex user authentication needs? And again, a very nice question. In case we deal with a 100% Firebase-driven app, user authentication may be performed with the help of Simple Login service which supports different networks; among them are Twitter, Facebook, Google, and GitHub. All these are in addition to a traditional email-password registration scheme. The nice thing about it is that in this case, you still don’t have to write any server-side code
A partially Firebase-powered application
However, sometimes a client is not capable of doing all the work on its own. Below we have such extraordinary situations:
- Your app is a more compound solution that couldn’t get along with writing a client-side code only. What’s more, your server-side code should be run on a credible server.
- You want your app to be integrated with some third-party APIs (to make it geolocation aware or to let it send SMS and emails)
- Your application is about advanced authentication needs, and Firebase Simple Login service is just not enough in this case.
If you already have an authentication system and want to integrate it with Firebase, the service also provides the Auth Token Generators for a number of languages. See, Firebase tries to cover all possible outcomes.
But this is just the tip of the iceberg. In fact, Firebase has much more of the exciting stuff to share…
2- Firebase Realtime Database
Realtime Database is a cloud-hosted database that allows you to store and sync data across all clients in real-time.
But what is the Firebase Database secret? Nice question, actually. The thing is, Realtime Database uses data synchronization instead of usual HTTP requests. So every time any data is changed, a connected client receives these changes in no time.
Moreover, the database is accessible directly from any client, be it a mobile device or a web browser. What it means is that your application doesn’t need any server-side code. Data are stored locally, which makes Firebase-powered apps responsive even though they go offline. Don’t worry, thanks to Realtime Database data synchronization, clients will receive all the data they missed during their absence once connectivity is renewed.
3- Firebase Cloud Messaging
Google Cloud Messaging becomes integrated with Firebase! What it means is that the company cloud-to-device messaging is available for Firebase users for free now.
The service is equally great for iOS, Android, and Web applications. So your users are going to benefit from a secure, real-time message exchange no matter what kind of device they use. If it comes to message targeting, there are typically three ways you can send messages to your clients: to certain devices, to groups of devices, and to the devices unified by some topic. Firebase is capable of transferring payloads of up to 4KB to a client app. At the same time, FCM is optimized for reliability and battery efficiency.
4- Firebase Storage
Need to give your users an opportunity to share and store multimedia through your application? No problem! Firebase Storage is always at your service. It provides secure uploads and downloads of users’ files even in poor network conditions. Using Firebase Storage SDKs, developers can upload and download content right from clients to Firebase Cloud, so they could be shared with anyone else. Firebase Auth and Storage work together to provide a secure sharing of the files on your app.
Hence, you can make files either public or private, limit access to certain groups of files, and control individual files to see.
A poor-quality network seems like a very unpleasant thing if you want to get your photos or videos immediately. But it’s not a big deal for Firebase, actually. In case the connection is lost, the client is able to continue uploading a file right from the point it was interrupted. That’s vital if it comes to transferring large-size objects. With Firebase Storage feature, your users’ time and bandwidth are safe, be sure.
What about scalability? I can say that you will never run out of space with Firebase Storage, just because it’s backed by Google Cloud Storage which scales to petabytes. Wow! It seems that your users will be able to share billions of photos, and you will never be forced to migrate to another storage provider.
5- Firebase Remote Config
Remote Config is yet another cloud service that obviously worth mentioning. This feature enables you to change the app appearance and behavior without having to ask your users to download its recent update. Mystery? Don’t think so.
Again, Firebase Console is here to help you get out of a fix. No more exhausting repeated releases just make some corrections to your application via Console, and no one will ever notice that there was something wrong with it just a couple of minutes ago.
6- Firebase Notifications
The next question how to make your users know that there is a message or other data to check? Easily! With the help of Notifications.
You use Firebase Notification Console to compose and send notifications to your client apps. In this case, no additional coding is required. FCM takes care of the notifications routing and delivery to targeted devices. They are the same: single, grouped, and unified by Firebase Cloud Messaging topic. User retention has never been so easy!
7- Firebase Crash Reporting
What is next, after Robo Test has finished with your application? Right, building a comprehensive bug report. As always, Firebase has an appropriate tool for this purpose.
Crash Reporting creates exhaustive reports on the errors that occurred in your app. These errors are sorted by their severity and grouped into clusters. What’s more, you can always track the issues by logging the events which led to them.
SO Should You Use Firebase?
If your app has any kind of backends needs, then Firebase probably has it ready for you to use. So yes, you should use it. Firebase comes from a trusted company such as Google and Firebase is used by some big names such as Shazam, The NewYork Times, Trivago, Alibaba and more.
Let me know in the comments why and for what you are using Firebase or if you are not using it do tell why not.
Best resources to learn firebase
- Firebase Cookbook: Over 70 recipes to help you create real-time web and mobile applications with Firebase
- Mastering Firebase for Android Development: Build real-time, scalable, and cloud-enabled Android apps with Firebase
- Basics Of Google Firebase For Web: Firebase 2019
- Build Mobile Apps with Ionic 4 and Firebase: Hybrid Mobile App Development