---
description: Unofficial Capacitor plugin for Firebase Cloud Firestore to use the Android and iOS SDKs in your Capacitor project.
title: Firebase Firestore Plugin for Capacitor - Capawesome
image: https://capawesome.io/docs/assets/images/social/blog/announcing-the-capacitor-firebase-cloud-firestore-plugin.png
---

[ Skip to content](#announcing-the-capacitor-firebase-cloud-firestore-plugin) 

[ 🔐 Introducing the **Capacitor Vault** plugin — store secrets behind biometrics or a device passcode.](/blog/announcing-the-capacitor-vault-plugin/) 

* [  Formbricks ](/docs/plugins/formbricks/)
* [  Geocoder ](/docs/plugins/geocoder/)
* [  Google Sign-In ](/docs/plugins/google-sign-in/)
* [  Grafana Faro ](/docs/plugins/grafana-faro/)
* [  libSQL ](/docs/plugins/libsql/)
* [  Live Update ](/docs/plugins/live-update/)
* [  Managed Configurations ](/docs/plugins/managed-configurations/)
* [  Media Session ](/docs/plugins/media-session/)
* [  ML Kit ](/docs/plugins/mlkit/)
* [  Navigation Bar ](/docs/plugins/navigation-bar/)
* [  NFC ](/docs/plugins/nfc/)
* [  OAuth ](/docs/plugins/oauth/)
* [  Pedometer ](/docs/plugins/pedometer/)
* [  Photo Editor ](/docs/plugins/photo-editor/)
* [  PostHog ](/docs/plugins/posthog/)
* [  Printer ](/docs/plugins/printer/)
* [  Purchases ](/docs/plugins/purchases/)
* [  RealtimeKit ](/docs/plugins/realtimekit/)
* [  Screen Orientation ](/docs/plugins/screen-orientation/)
* [  Screenshot ](/docs/plugins/screenshot/)
* [  Secure Preferences ](/docs/plugins/secure-preferences/)
* [  Speech Recognition ](/docs/plugins/speech-recognition/)
* [  Speech Synthesis ](/docs/plugins/speech-synthesis/)
* [  Share Target ](/docs/plugins/share-target/)
* [  Square Mobile Payments ](/docs/plugins/square-mobile-payments/)
* [  SQLite ](/docs/plugins/sqlite/)
* [  Superwall ](/docs/plugins/superwall/)
* [  Torch ](/docs/plugins/torch/)
* [  Vault ](/docs/plugins/vault/)
* [  Wifi ](/docs/plugins/wifi/)
* [  Zip ](/docs/plugins/zip/)
* [  Cloud ](/docs/cloud/)
* [  Live Updates ](/docs/cloud/live-updates/)
* Advanced
* Integrations
* [  Native Builds ](/docs/cloud/native-builds/)
* [  Configuration ](/docs/cloud/native-builds/configuration/)
* [  Environments ](/docs/cloud/native-builds/environments/)
* Guides
* [  Sample Projects ](/docs/cloud/native-builds/sample-projects/)
* [  Troubleshooting ](/docs/cloud/native-builds/troubleshooting/)
* [  Automations ](/docs/cloud/automations/)
* [  Assist ](/docs/cloud/assist/)
* Account
* Organizations
* [  Organization and User Management ](/docs/cloud/organizations/memberships/)
* [  Single Sign-On (SSO) ](/docs/cloud/organizations/sso/)
* [  Teams ](/docs/cloud/organizations/teams/)
* [  Two-Factor Authentication ](/docs/cloud/organizations/two-factor-authentication/)
* [  Integrations ](/docs/cloud/integrations/)
* [  License Keys ](/docs/cloud/license-keys/)
* [  Webhooks ](/docs/cloud/webhooks/)
* [  Pricing ](https://capawesome.io/pricing/)
* [  FAQ ](/docs/cloud/faq/)
* [  Support ](/docs/cloud/support/)
* [  Contributing ](/docs/contributing/)
* [  LLMs ](/docs/llms/)
* [  Insiders ](/docs/insiders/)
* [  License ](https://capawesome.io/legal/eula/)
* [  Support ](/docs/insiders/support/)
* [  FAQ ](/docs/insiders/faq/)
* [  Blog ](/blog/)
* Categories

* [  Limitations ](#limitations)
* [  Closing Thoughts ](#closing-thoughts)

* Related links

# Announcing the Capacitor Firebase Cloud Firestore Plugin[¶](#announcing-the-capacitor-firebase-cloud-firestore-plugin "Permanent link")

Today we are excited to announce the release of the [Capacitor Firebase Cloud Firestore](/docs/plugins/firebase/cloud-firestore/) plugin, sponsored by [AppScreens](https://appscreens.com/?%5Flocale=en&utm%5Fsource=capawesome&utm%5Fmedium=referral&utm%5Fcampaign=capawesome&gclid=capawesome). This plugin allows you to use the Android and iOS SDKs for [Firebase Cloud Firestore](https://firebase.google.com/docs/firestore) in your Capacitor project.

Until now, it was necessary to use the Firebase JavaScript SDK on Android and iOS as well to use Cloud Firestore. However, this had some drawbacks, such as the need for additional authentication of users in the web layer and degraded performance. The Capacitor Firebase Cloud Firestore plugin addresses these drawbacks by providing a native implementation for Android and iOS.

![Demo](/blog/announcing-the-capacitor-firebase-cloud-firestore-plugin/1bb26bb3-308a-4062-aef1-7c49e983d8fe.gif) 

Demo

Let's take a quick look at the [Capacitor Firebase Cloud Firestore API](/docs/plugins/firebase/cloud-firestore/#api) and how you can add, get and delete data from your database.

## Installation[¶](#installation "Permanent link")

Run the following commands to install the plugin:

`[](#%5F%5Fcodelineno-0-1)npm install @capacitor-firebase/firestore
[](#%5F%5Fcodelineno-0-2)npx cap sync
`

You also need to [add Firebase to your project](https://github.com/capawesome-team/capacitor-firebase/blob/main/docs/firebase-setup.md) if you haven't already.

## Usage[¶](#usage "Permanent link")

If you are new to Cloud Firestore, we recommend that you first read the [Understand Cloud Firestore](https://firebase.google.com/docs/firestore) section so that you are familiar with the basics. Let's see the plugin in action.

### Add data[¶](#add-data "Permanent link")

There are several ways to write data to Cloud Firestore. One way is to add a new document to a collection with an automatically generated document identifier using the [addDocument(...)](/docs/plugins/firebase/cloud-firestore/#adddocument) method:

`[](#%5F%5Fcodelineno-1-1)import { FirebaseFirestore } from '@capacitor-firebase/firestore';
[](#%5F%5Fcodelineno-1-2)
[](#%5F%5Fcodelineno-1-3)const addDocument = async () => {
[](#%5F%5Fcodelineno-1-4)  const { reference } = await FirebaseFirestore.addDocument({
[](#%5F%5Fcodelineno-1-5)    reference: 'users',
[](#%5F%5Fcodelineno-1-6)    data: { 
[](#%5F%5Fcodelineno-1-7)      first: 'Alan', 
[](#%5F%5Fcodelineno-1-8)      last: 'Turing', 
[](#%5F%5Fcodelineno-1-9)      born: 1912 
[](#%5F%5Fcodelineno-1-10)    },
[](#%5F%5Fcodelineno-1-11)  });
[](#%5F%5Fcodelineno-1-12)  return reference.id;
[](#%5F%5Fcodelineno-1-13)};
`

In this case we add a new document with the data `{ first: 'Alan', last: 'Turing', born: 1912 }` to the collection `users`.

Another way is to set the content of a document within a collection by explicitly specifying a document identifier using the [setDocument(...)](/docs/plugins/firebase/cloud-firestore/#setdocument) method:

`[](#%5F%5Fcodelineno-2-1)import { FirebaseFirestore } from '@capacitor-firebase/firestore';
[](#%5F%5Fcodelineno-2-2)
[](#%5F%5Fcodelineno-2-3)const setDocument = async () => {
[](#%5F%5Fcodelineno-2-4)  await FirebaseFirestore.setDocument({
[](#%5F%5Fcodelineno-2-5)    reference: 'users/Aorq09lkt1ynbR7xhTUx',
[](#%5F%5Fcodelineno-2-6)    data: { 
[](#%5F%5Fcodelineno-2-7)      first: 'Alan', 
[](#%5F%5Fcodelineno-2-8)      last: 'Turing', 
[](#%5F%5Fcodelineno-2-9)      born: 1912 
[](#%5F%5Fcodelineno-2-10)    },
[](#%5F%5Fcodelineno-2-11)    merge: true,
[](#%5F%5Fcodelineno-2-12)  });
[](#%5F%5Fcodelineno-2-13)};
`

Use `{ merge: boolean }` to specify whether the newly provided data should overwrite the content of the document or be merged with the existing document.

### Get data[¶](#get-data "Permanent link")

To retrieve a single document from a collection, you can use the [getDocument(...)](/docs/plugins/firebase/cloud-firestore/#getdocument) method:

`[](#%5F%5Fcodelineno-3-1)import { FirebaseFirestore } from '@capacitor-firebase/firestore';
[](#%5F%5Fcodelineno-3-2)
[](#%5F%5Fcodelineno-3-3)const getDocument = async () => {
[](#%5F%5Fcodelineno-3-4)  const { snapshot } = await FirebaseFirestore.getDocument({
[](#%5F%5Fcodelineno-3-5)    reference: 'users/Aorq09lkt1ynbR7xhTUx',
[](#%5F%5Fcodelineno-3-6)  });
[](#%5F%5Fcodelineno-3-7)  return snapshot;
[](#%5F%5Fcodelineno-3-8)};
`

You just need to pass the document reference as a string, with path components separated by a forward slash (`/`).

To retrieve multiple documents from a collection, you can use the [getCollection(...)](/docs/plugins/firebase/cloud-firestore/#getcollection) method:

`[](#%5F%5Fcodelineno-4-1)import { FirebaseFirestore } from '@capacitor-firebase/firestore';
[](#%5F%5Fcodelineno-4-2)
[](#%5F%5Fcodelineno-4-3)const getCollection = async () => {
[](#%5F%5Fcodelineno-4-4)  const { snapshots } = await FirebaseFirestore.getCollection({
[](#%5F%5Fcodelineno-4-5)    reference: 'users',
[](#%5F%5Fcodelineno-4-6)    compositeFilter: {
[](#%5F%5Fcodelineno-4-7)      type: 'and',
[](#%5F%5Fcodelineno-4-8)      queryConstraints: [
[](#%5F%5Fcodelineno-4-9)        {
[](#%5F%5Fcodelineno-4-10)          type: 'where',
[](#%5F%5Fcodelineno-4-11)          fieldPath: 'born',
[](#%5F%5Fcodelineno-4-12)          opStr: '==',
[](#%5F%5Fcodelineno-4-13)          value: 1912,
[](#%5F%5Fcodelineno-4-14)        },
[](#%5F%5Fcodelineno-4-15)      ],
[](#%5F%5Fcodelineno-4-16)    },
[](#%5F%5Fcodelineno-4-17)    queryConstraints: [
[](#%5F%5Fcodelineno-4-18)      {
[](#%5F%5Fcodelineno-4-19)        type: 'orderBy',
[](#%5F%5Fcodelineno-4-20)        fieldPath: 'born',
[](#%5F%5Fcodelineno-4-21)        directionStr: 'desc',
[](#%5F%5Fcodelineno-4-22)      },
[](#%5F%5Fcodelineno-4-23)      {
[](#%5F%5Fcodelineno-4-24)        type: 'limit',
[](#%5F%5Fcodelineno-4-25)        limit: 10,
[](#%5F%5Fcodelineno-4-26)      },
[](#%5F%5Fcodelineno-4-27)    ],
[](#%5F%5Fcodelineno-4-28)  });
[](#%5F%5Fcodelineno-4-29)  return snapshots;
[](#%5F%5Fcodelineno-4-30)};
`

This method allows you to apply filters and sorting to the query. It is recommended that you specify the `type` property first, so that TypeScript will list the remaining properties for you.

### Delete data[¶](#delete-data "Permanent link")

To delete a document from a collection, you can use the [deleteDocument(...)](/docs/plugins/firebase/cloud-firestore/#deletedocument) method:

`[](#%5F%5Fcodelineno-5-1)import { FirebaseFirestore } from '@capacitor-firebase/firestore';
[](#%5F%5Fcodelineno-5-2)
[](#%5F%5Fcodelineno-5-3)const deleteDocument = async () => {
[](#%5F%5Fcodelineno-5-4)  await FirebaseFirestore.deleteDocument({
[](#%5F%5Fcodelineno-5-5)    reference: 'users/Aorq09lkt1ynbR7xhTUx',
[](#%5F%5Fcodelineno-5-6)  });
[](#%5F%5Fcodelineno-5-7)};
`

Again you just need to pass the document reference as a string, with path components separated by a forward slash (`/`).

### Get real-time updates[¶](#get-real-time-updates "Permanent link")

If you want to get real-time updates when documents change, you can use the [addDocumentSnapshotListener(...)](/docs/plugins/firebase/cloud-firestore/#adddocumentsnapshotlistener) and [addCollectionSnapshotListener(...)](/docs/plugins/firebase/cloud-firestore/#addcollectionsnapshotlistener) methods:

`[](#%5F%5Fcodelineno-6-1)import { FirebaseFirestore } from '@capacitor-firebase/firestore';
[](#%5F%5Fcodelineno-6-2)
[](#%5F%5Fcodelineno-6-3)
[](#%5F%5Fcodelineno-6-4)const addDocumentSnapshotListener = async () => {
[](#%5F%5Fcodelineno-6-5)  const callbackId = await FirebaseFirestore.addDocumentSnapshotListener(
[](#%5F%5Fcodelineno-6-6)    {
[](#%5F%5Fcodelineno-6-7)      reference: 'users/Aorq09lkt1ynbR7xhTUx',
[](#%5F%5Fcodelineno-6-8)    },
[](#%5F%5Fcodelineno-6-9)    (event, error) => {
[](#%5F%5Fcodelineno-6-10)      if (error) {
[](#%5F%5Fcodelineno-6-11)        console.error(error);
[](#%5F%5Fcodelineno-6-12)      } else {
[](#%5F%5Fcodelineno-6-13)        console.log(event);
[](#%5F%5Fcodelineno-6-14)      }
[](#%5F%5Fcodelineno-6-15)    }
[](#%5F%5Fcodelineno-6-16)  );
[](#%5F%5Fcodelineno-6-17)  return callbackId;
[](#%5F%5Fcodelineno-6-18)};
[](#%5F%5Fcodelineno-6-19)
[](#%5F%5Fcodelineno-6-20)const addCollectionSnapshotListener = async () => {
[](#%5F%5Fcodelineno-6-21)  const callbackId = await FirebaseFirestore.addCollectionSnapshotListener(
[](#%5F%5Fcodelineno-6-22)    {
[](#%5F%5Fcodelineno-6-23)      reference: 'users',
[](#%5F%5Fcodelineno-6-24)    },
[](#%5F%5Fcodelineno-6-25)    (event, error) => {
[](#%5F%5Fcodelineno-6-26)      if (error) {
[](#%5F%5Fcodelineno-6-27)        console.error(error);
[](#%5F%5Fcodelineno-6-28)      } else {
[](#%5F%5Fcodelineno-6-29)        console.log(event);
[](#%5F%5Fcodelineno-6-30)      }
[](#%5F%5Fcodelineno-6-31)    }
[](#%5F%5Fcodelineno-6-32)  );
[](#%5F%5Fcodelineno-6-33)  return callbackId;
[](#%5F%5Fcodelineno-6-34)};
`

The callback function will be called every time the document or collection changes. To remove the listener, you have to call the [removeSnapshotListener(...)](/docs/plugins/firebase/cloud-firestore/#removesnapshotlistener) or [removeAllListeners()](/docs/plugins/firebase/cloud-firestore/#removealllisteners) methods:

`[](#%5F%5Fcodelineno-7-1)import { FirebaseFirestore } from '@capacitor-firebase/firestore';
[](#%5F%5Fcodelineno-7-2)
[](#%5F%5Fcodelineno-7-3)const removeSnapshotListener = async (callbackId: string) => {
[](#%5F%5Fcodelineno-7-4)  await FirebaseFirestore.removeSnapshotListener({
[](#%5F%5Fcodelineno-7-5)    callbackId,
[](#%5F%5Fcodelineno-7-6)  });
[](#%5F%5Fcodelineno-7-7)};
[](#%5F%5Fcodelineno-7-8)
[](#%5F%5Fcodelineno-7-9)const removeAllListeners = async () => {
[](#%5F%5Fcodelineno-7-10)  await FirebaseFirestore.removeAllListeners();
[](#%5F%5Fcodelineno-7-11)};
`

## Limitations[¶](#limitations "Permanent link")

Currently, there are still a few limitations that you need to be aware of:

1. **Data types**: The supported data types are those that can be represented in JSON such as numbers, strings, booleans, arrays, and objects. Something that is not currently supported is, for example, the JavaScript `Date` object. However, you can just pass the `Date` as a `string` by using the `toISOString()` method:  
`[](#%5F%5Fcodelineno-8-1)// Create a string representation of the current date based on ISO 8601  
[](#%5F%5Fcodelineno-8-2)const dateString = new Date().toISOString();  
[](#%5F%5Fcodelineno-8-3)// Create a new date object from the string  
[](#%5F%5Fcodelineno-8-4)const date = new Date(dateString);  
`
2. **Field values**: Firestore supports various field values such as `FieldValue.delete()`, `FieldValue.increment()` or `FieldValue.serverTimestamp()`. However, these will not be supported until the next release (see [capacitor-firebase/issues/443](https://github.com/capawesome-team/capacitor-firebase/issues/443)).

## Closing Thoughts[¶](#closing-thoughts "Permanent link")

Be sure to check out our [API Reference](/docs/plugins/firebase/cloud-firestore/#api) to see what else you can do with this plugin. Also feel free to check out our base sponsor [AppScreens](https://appscreens.com/?%5Flocale=en&utm%5Fsource=capawesome&utm%5Fmedium=referral&utm%5Fcampaign=capawesome&gclid=capawesome) \- a dedicated screenshot mockup generator for app developers.

May 7, 2026 

 Back to top 