Firebase with Angular: an Easy Way to Set Up the Server Side of Your App
In this article, SoftTeco’s software engineer Boris explains how you can use Google’s Firebase to set up the server part of your application written in Angular. Note though that the use of Firebase is not limited by Angular only - in fact, you can use FIrebase with almost any language and for an app of any type and complexity.
What is Firebase and why is it so good?
Firebase is a BaaS (backend as a service) platform by Google that allows developers to easily set up the whole server part of an application. Firebase weaves together a server, a database, storage, hosting, and authentication - all in one platform.
Such an approach eliminates the need to focus on many processes, related to the server setup, such as database creation or writing an API. Instead, all these processes are managed by Firebase which allows developers to save a significant amount of time and create a working module of almost any functionality in approximately a day.
Hence, the biggest benefits of using Firebase are:
- Quick and easy setup;
- Saving time due to automation of processes;
- Scalability (suitable for different projects).
The main thing to remember about Firebase is that it consists of five modules, each responsible for a specific task. Let’s look at them in more detail.
As you can guess from the name, the Firebase Authentication module enables user authentication for your app. Its main responsibilities are:
- Integration with numerous services;
- Access management via guard;
- Monitoring the authorization state of users.
Needless to say, Firebase Auth provides a high level of security when it comes to processing user data but we still recommend following the basic steps of app security to ensure your product is securely safeguarded.
This module is a cloud-hosted database where data is stored in JSON format. The main things to remember about Firebase Database are:
- This is a NoSQL real-time database;
- Sampling and sorting are available;
- Offline mode is available;
- Indexing and scaling.
One more great thing about Firebase Database is that it can be accessed from both a web browser and a mobile device and it does not require an application server. The data is validated through the Firebase Realtime Database Security Rules.
This module is responsible for storing and managing user-generated content such as images and videos. And since this module is backed by Google Cloud Storage, you won’t have to worry about the security of the data as Firebase takes good care of it. Access control also contributes to high security as you can set up the access roles and monitor who can access the data.
Other useful features of Firebase Storage include convenient data reception through the pipes and efficient organization of folders where the data is stored. Hence, this module is easy to operate and doesn’t require much effort to get a grasp on it.
Firebase Functions is a serverless technology that can automatically run the server code in response to events triggered by Firebase and HTTPS requests. This module processes the data and manages logs and connections between all Firebase modules.
What’s great about Functions is that this module is private and secure and the client cannot access it. This is an advantage if you don’t want any reverse engineering or tampering on the client’s side. As well, Firebase Functions free developers from the need to manage credentials, server configuration, or new servers provisioning as the module independently matches the available computing resources with user needs.
This module is a fully managed hosting service that can be also used for microservices. It is backed by SSD storage and works with the global CDN. Same as other Firebase modules, Hosting is very easy to manage and offers a quick and hassle-free setup and state recovery. You can integrate Hosting with Cloud Firestore if you want to build a complex and powerful app with real-time data updates.
Firebase pros and cons
As you can see by now, Firebase is an efficient solution that doesn’t require too much effort from developers. Let’s list its biggest pros and cons below.
- Quick setup;
- Ease of use;
- Fast performance;
- Suitable for POC, MVP, PetProjects;
- Rich documentation;
- A vast number of available modules and integrations.
- Non-relational (NoSQL) database which is not very suitable for complex, massive apps;
- Price (can be really high in case your app grows).
Overall, Firebase can be used for a project of any type and size due to its scalability but you have to keep in mind that the price will grow correspondingly to the project’s growth. Therefore, I recommend using Firebase mainly for small projects and MVPs as it will deliver the best price: quality ratio in this case.
SoftTecoView all articles by this author.