See all Blogs

Shahroz Bakht

Firebase Data Bundles

Firestore data bundles are the new hit in the market. Through this version, we will now be able to use the Firestore bundle in our cellphones and web application! Isn’t that great? Not just that but these data bundles make Firestore application much faster and affordable.

Data bundles:

These are groups of documents that are either individual or several documents that are retrieved using a specific query.

These easy-to-operate data bundles, can save the data bundle onto a CDN or any object storage server and then load them from your client applications, once that your clients can read them in from your local cache.

Why use it:

The major cause of using this is to avoid making extra calls against the database by having clients read common queries from a bundle on CDN and then querying specifically against cached data, which saves money and is potentially faster.

Documents to put into bundles:

The best bundles are ones in which the majority of the documents read by the users are kept in the same bundles with a limited number of documents with little changes from time to time. Like storing configuration data across several documents that every client needs to read in upon startup would be great to put in bundles as millions of clients would be reading it.

Data bundle cons:

Data bundles are not good if the user will be asking for a different piece of information. Any data that contain private information cannot be used due to the privacy issue as it is to be read by the general public because data bundle are created by server SDK and can bypass security rule.

Stuffing the entire database into a bundle:

  • It would be terrible to stuff a heap full of documents into a bundle keeping in mind the Firestore cache is not particularly fast. Overloading with the document that the user won’t ever use will only slow down the server.
  • You have to load the entire bundle of documents when loading a bundle, so from a data usage perspective stuffing too many documents can be pretty heavy.

How it works:

  • Generate a bundle either an individual document or generated through a query.
  • These bundle on CDN or object storing server like cloud storage.
  • When the client startup, tell them to load the bundle using any networking library.
  • Once the bundles are loaded, the firestore SDK can merge them with any cached data you might already have and make use of them like any other cached data.


  • To save cost it's better to force the client to use cached data. Making a document request adding an option {source: ‘cache’} that directs the client to use cached data.
  • Using a named query ensures that the client will always make the same query that generated the bundle in the first place and less room for error that way.

These Firestore data bundles are one step ahead to make you in making your work organized and even more effective.

  See all Blogs