Why everyone is using Firebase and Why you should too

Subscribe to my newsletter and never miss my upcoming articles

What is FireBase?

social.png

Firebase is Backend as a Service (BaaS) where it takes care of user authentication, Database and hosting all by itself.

My Experience with Firebase

I have personally built 3 production-level projects using most of the firebase features and I have faced 0 problems with it and the best part I haven't spent a single penny on it.

3 Reasons Why you Should Care about Firebase

  • Experience - Firebase has the best documentation and has good support in case you are stuck somewhere.
  • Price - It's free for your small/experimental projects and you can pay as you go if the project grows linearly
  • Maximize Time - You can implement a lot of features in less time with small code

Go To console.firebase.com and explore by creating a project inside but before that have a look at this article.

What does Firebase offer?

  • Authentication
  • Firestore (NO SQL Database)
  • Hosting
  • Cloud Functions

Authentication

If you have to build an application which has “login” features you definitely know building an authentication system with encryption and other things involved is a pain.

hash3.png With Firebase authentication you can let users log in with email or even let users log in to your product via Google Sign in with a small piece of Code. Here is the documentation for Google sign in method and email sign in method

FireStore

If you are a computer science student you might have learnt MYSQL which is a relation based SQL DBMS.

Firestore is No SQL database like Mongo DB which is made of Collections and Documents stored in JSON format. It has its own pros and cons. For beginners, this is very easy to learn, even querying/filtering is so much better.

hash4.PNG

Let's say that we have to keep information about a user and keep a record of his order history. For that, we will build 2 collections

-Users -Orders

which will have a document inside with information stored in JSON format.

hash5.PNG

Hosting

So you have now built a Web App using Firebase and need to host it somewhere. Well, Firebase has got your back. Make sure that you have a folder with the public as a name which would have your index.html file. Project Structure should look something like this hash6.PNG Run the following commands to deploy your web app to firebase.

Firebase init

In Response, you get this

? Are you ready to proceed? Yes
? Which Firebase CLI features do you want to set up for this folder? Press Space to select features, then Enter to confirm your choices.
 ( ) Database: Deploy Firebase Realtime Database Rules
 ( ) Firestore: Deploy rules and create indexes for Firestore
 ( ) Functions: Configure and deploy Cloud Functions
>(*) Hosting: Configure and deploy Firebase Hosting sites
 ( ) Storage: Deploy Cloud Storage security rules
 ( ) Emulators: Set up local emulators for Firebase features

Choose the services as hosting and select a public folder where you should have your index.html inside. This is how it should look

=== Hosting Setup

Your public directory is the folder (relative to your project directory) that
will contain Hosting assets to be uploaded with firebase deploy. If you
have a build process for your assets, use your build's output directory.

? What do you want to use as your public directory? public
? Configure as a single-page app (rewrite all urls to /index.html)? Yes
? File public/index.html already exists. Overwrite? (y/N) N

After the initialization, you can deploy it with this code

firebase deploy

You might want to connect your own domain or might get stuck at something. Refer to the Firebase Hosting Documentation for better reference.

Cloud Functions

This is one of the favourite things about Firebase is cloud Functions. I might write a few articles down the lane so stay tuned.

Cloud Functions is a hosted, private, and scalable Node.js environment where you can run JavaScript code. Cloud Functions for Firebase integrates the Firebase platform by letting you write code that responds to events and invokes functionality exposed by other Firebase features.

And it has a lot of interesting use cases, like:

You can host only 2 cloud Functions for free of cost in a Spark plan, just keep that in mind.

Is Firebase used in tech companies?

Yes. Usually by startups without a lot of time and resources. Firebase is a godsend.

But not in big corporates where securing user data is a bigger priority, they prefer building it inhouse instead of using BaaS like firebase.

(The other reason why few companies don't prefer firebase is that the product they are building might be for global users and we know that some countries have banned google and hence firebase won't work there.)

Don't' worry though . if you understand how NO-SQL works using firebase, It's pretty similar to mongo, so it won't be a challenge.

In conclusion:

Firebase is easily the best backend as a service for beginners or freelancers who are just getting off the ground.


I will soon write on how you can integrate Firebase to Flask apps to stay tuned to my newsletter and follow me here on Hashnode.

Bright Okwu's photo

Nice article...

Rahul Kamath's photo

Wait, does this have the option to add "sign in with Apple"?

If not, how do you do that?

Hrithwik Bharadwaj's photo

You can let users sign in with Twitter/GitHub/Apple or any other major service . Just go to Firebase console, open authentication, in there head over to sign in method and choose apple

Thoby Victor's photo

Wow, really nice article. I love the simplicity of the deploying of both cloud and hosting at their basics.