Firebase Dev Checklist for your Next Project #StartWithSkcript
In this first of #StartWithSkcript series, we dive into how to start your next project with Firebase. These are some of the steps we follow when we scaffold a project with Firebase. Read on to learn more
Are you planning to develop your next application with Firebase? Then this is what you must read before you jump in and write your first code. In this article, I write about what are the key important things you need to do before you code your project with firebase. Many of these are very common for all the firebase projects so you better read the entire article.
In this article, I’ll be taking an example of react app using firestore as the backend.
Setup the rules#
When you create a firebase project and planning to use firestore, set up the rule to locked mode as the first step. This is mainly to prevent any unwanted users to read or write data without proper permission. Rules are very crucial for your application, so don’t take it easy.
Hosting Domain Mapping#
Hosting is one of the best features of firebase which helps you package your entire application in one place and help you manage it a lot better. If your application is a SPA or built with client-side frameworks like React or Angular, I strongly suggest you use hosting and map your domain name with it.
My favorite part about this is that firebase handles the load balancing when you’re traffic hikes. Also, it comes with an SSL certificate.
Authentication Whitelist Only Production Domain#
A lot of people miss this part where when they enable the authentication, by default for apps to allow user signup in their dev environment the localhost domain is whitelisted in firebase console. This has to be removed when we go to production and have only the production domains to be allowed.
The major reason is that when you develop a web app and all the credentials are present in the browser, it’s easy for anyone to mimic your application on their local if localhost is not blacklisted. Which is a very serious threat.
Write heavy operations in Firebase Cloud Functions#
The main goal of firebase is that you can build applications without developing a backend server. But there are cases where you have to rely on a backend server where your frontend (Browser or mobile apps) won’t scale, important things like sending an email, push notifications, processing an image or media files, etc.
For such cases, it’s highly recommended to use Firebase Cloud Functions. These functions are running in Google’s servers on specific triggers. I very commonly use functions for many of the background processing like ones mentioned above, incrementing counters, deleting dependent data when a data is destroyed or user is deleted.
Prefer Firestore over Realtime DB for complex applications#
Real-time databases are faster than firestore, but when you develop an application that has multiple datasets and does complex operations you should prefer firestore. Firestore is a NoSQL Database hosted within each firebase project. The best part of Firestore is that it supports a lot of queries that are not possible with Real-time Databases.