๐Ÿ”ฅ Firebase Best Practicesยถ

Firebase is the name of a mobile platform from Google that makes it easy to build a back-end that is both scalable and efficient. In other words, it is a platform that allows the rapid development of mobile and web applications.

Firebase itself, however, is more than just a database. Itโ€™s a complete product with API interfaces, an integrated auth platform, and associated cloud functions to leverage micro-service, back-end construction for things that need to be hidden on a server, such as payment processing.

What is Firebase Cloud Firestore?ยถ

The Firebase Cloud Firestore is a NoSQL database provided by Google Firebase. It provides real-time syncing between the cloud database and the client app, it stores data in hierarchical data structures which are documents organized into collections.

Firestore Best Practicesยถ

Add Rulesยถ

When you create your Firebase Firestore Database itโ€™s by default open to the internet on test mode, make sure to add the required Firestore Rules to secure your data and your app.

Denormalize Dataยถ

When you need deep nesting functionality, consider adding a couple of different collections, even when you need to add some data duplication and use more than one request to retrieve what you need.

Document IDsยถ

Avoid the document IDs like โ€ . โ€œ, โ€œโ€ฆโ€, and โ€œ/โ€, also do not use monotonically increasing document IDs such as: โ€œCustomer1, Customer2, Customer3, โ€ฆโ€. Do use auto-generated IDs.

Field Namesยถ

Avoid the following characters in field names because they require extra escaping: โ€œโ€, โ€œ[, ]โ€, โ€œ*โ€, โ€œ`โ€

What is Firebase Authentication?ยถ

With Firebase Authentication, building secure authentication systems is a snap. This tool also gives your end users a better onboarding and signing-in experience.

Authentication best practicesยถ

Combine Firestore with Authยถ

As your app will grow and you will have to handle an important number of users it is required to add a new collection to Firestore โ€œUsersโ€ to save your userโ€™s data.

Verify Your Usersยถ

To make sure your app is secured, and not vulnerable, you must implement email verification to users signed up with email/password.

Keep Users Data Safeยถ

When we use Firestore to store our app usersโ€™ data make sure to never save your userโ€™s passwords! Also saving their e-mails is a bad practice.

What is Firebase Storage?ยถ

Firebase Storage allows you to share or store content produced by your users such as images, videos, or even audio files. It is a powerful object storage solution that stands out for its simplicity and cost-efficiency. Storage Best Practices

Add Your Rulesยถ

Just like securing Firestore Database with rules, we can secure Storage with rules, they are here for a reason, so do add them!

Limit Bandwidth Usageยถ

If your users have the access to share and deploy pictures or videos in your app, make sure to compress and resize the files before or after they get uploaded, or you risk paying dearly.