---
description: Unofficial Capacitor plugin for Firebase Cloud Firestore SDK to store and sync data in real-time with support for Android, iOS, and Web.
title: Capacitor Firestore Plugin for Android, iOS & Web - Capawesome
image: https://capawesome.io/docs/assets/images/social/plugins/firebase/cloud-firestore.png
---

[ Skip to content](#capacitor-firebasefirestore) 

[ 🎉 Introducing **Capawesome Platform** — one platform for Live Updates, Native Builds, App Store Publishing, and Insider SDKs.](https://capawesome.io) 

* [  Configuration ](#configuration)
* [  Demo ](#demo)
* [  Starter templates ](#starter-templates)
* [  Usage ](#usage)
* [  API ](#api)
* [  Type Aliases ](#type-aliases)
* [  Changelog ](#changelog)
* [  License ](#license)
* [  Cloud Functions ](/docs/plugins/firebase/cloud-functions/)
* [  Cloud Messaging ](/docs/plugins/firebase/cloud-messaging/)
* [  Cloud Storage ](/docs/plugins/firebase/cloud-storage/)
* [  Performance Monitoring ](/docs/plugins/firebase/performance-monitoring/)
* [  Remote Config ](/docs/plugins/firebase/remote-config/)
* [  Formbricks ](/docs/plugins/formbricks/)
* [  Geocoder ](/docs/plugins/geocoder/)
* [  Google Sign-In ](/docs/plugins/google-sign-in/)
* [  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/)
* [  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/)
* [  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

* [  Configuration ](#configuration)
* [  Demo ](#demo)
* [  Starter templates ](#starter-templates)
* [  Usage ](#usage)
* [  API ](#api)
* [  Type Aliases ](#type-aliases)
* [  Changelog ](#changelog)
* [  License ](#license)

# @capacitor-firebase/firestore[¶](#capacitor-firebasefirestore "Permanent link")

Unofficial Capacitor plugin for [Firebase Cloud Firestore](https://firebase.google.com/docs/firestore/).[1](#fn:1)

[ ![Deliver Live Updates to your Capacitor app with Capawesome Cloud](../../../assets/external/cloud.capawesome.io/assets/banners/cloud-build-and-deploy-capacitor-apps.69628c3f.png) ](https://cloud.capawesome.io/) 

## Guides[¶](#guides "Permanent link")

* [Announcing the Capacitor Firebase Cloud Firestore Plugin](https://capawesome.io/blog/announcing-the-capacitor-firebase-cloud-firestore-plugin/)

## Newsletter[¶](#newsletter "Permanent link")

Stay up to date with the latest news and updates about the Capawesome, Capacitor, and Ionic ecosystem by subscribing to our [Capawesome Newsletter](https://cloud.capawesome.io/newsletter/).

## Compatibility[¶](#compatibility "Permanent link")

| Plugin Version | Capacitor Version | Status         |
| -------------- | ----------------- | -------------- |
| 8.x.x          | \>=8.x.x          | Active support |
| 7.x.x          | 7.x.x             | Deprecated     |
| 6.x.x          | 6.x.x             | Deprecated     |

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

You can use our **AI-Assisted Setup** to install the plugin. Add the [Capawesome Skills](https://github.com/capawesome-team/skills) to your AI tool using the following command:

`[](#%5F%5Fcodelineno-0-1)npx skills add capawesome-team/skills --skill capacitor-plugins
`

Then use the following prompt:

`` [](#%5F%5Fcodelineno-1-1)Use the `capacitor-plugins` skill from `capawesome-team/skills` to install the `@capacitor-firebase/firestore` plugin in my project.
 ``

If you prefer **Manual Setup**, install the plugin by running the following commands and follow the platform-specific instructions below:

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

Add Firebase to your project if you haven't already ([Android](https://github.com/capawesome-team/capacitor-firebase/blob/main/docs/firebase-setup.md#android) / [iOS](https://github.com/capawesome-team/capacitor-firebase/blob/main/docs/firebase-setup.md#ios) / [Web](https://github.com/capawesome-team/capacitor-firebase/blob/main/docs/firebase-setup.md#web)).

### Android[¶](#android "Permanent link")

#### Variables[¶](#variables "Permanent link")

If needed, you can define the following project variable in your app’s `variables.gradle` file to change the default version of the dependency:

* `$firebaseFirestoreVersion` version of `com.google.firebase:firebase-firestore` (default: `26.0.2`)

This can be useful if you encounter dependency conflicts with other plugins in your project.

## Configuration[¶](#configuration "Permanent link")

These configuration values are available:

| Prop           | Type   | Description                                                                           | Since |
| -------------- | ------ | ------------------------------------------------------------------------------------- | ----- |
| **databaseId** | string | The database ID of the Firestore database to use. Only available for Android and iOS. | 8.2.0 |

### Examples[¶](#examples "Permanent link")

In `capacitor.config.json`:

`[](#%5F%5Fcodelineno-3-1){
[](#%5F%5Fcodelineno-3-2)  "plugins": {
[](#%5F%5Fcodelineno-3-3)    "FirebaseFirestore": {
[](#%5F%5Fcodelineno-3-4)      "databaseId": undefined
[](#%5F%5Fcodelineno-3-5)    }
[](#%5F%5Fcodelineno-3-6)  }
[](#%5F%5Fcodelineno-3-7)}
`

In `capacitor.config.ts`:

`[](#%5F%5Fcodelineno-4-1)/// <reference types="@capacitor-firebase/firestore" />
[](#%5F%5Fcodelineno-4-2)
[](#%5F%5Fcodelineno-4-3)import { CapacitorConfig } from '@capacitor/cli';
[](#%5F%5Fcodelineno-4-4)
[](#%5F%5Fcodelineno-4-5)const config: CapacitorConfig = {
[](#%5F%5Fcodelineno-4-6)  plugins: {
[](#%5F%5Fcodelineno-4-7)    FirebaseFirestore: {
[](#%5F%5Fcodelineno-4-8)      databaseId: undefined,
[](#%5F%5Fcodelineno-4-9)    },
[](#%5F%5Fcodelineno-4-10)  },
[](#%5F%5Fcodelineno-4-11)};
[](#%5F%5Fcodelineno-4-12)
[](#%5F%5Fcodelineno-4-13)export default config;
`

## Demo[¶](#demo "Permanent link")

A working example can be found here: [robingenz/capacitor-firebase-plugin-demo](https://github.com/robingenz/capacitor-firebase-plugin-demo)

## Starter templates[¶](#starter-templates "Permanent link")

The following starter templates are available:

* [Ionstarter Angular Firebase](https://ionstarter.dev/)

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

`[](#%5F%5Fcodelineno-5-1)import { FirebaseFirestore } from '@capacitor-firebase/firestore';
[](#%5F%5Fcodelineno-5-2)
[](#%5F%5Fcodelineno-5-3)const addDocument = async () => {
[](#%5F%5Fcodelineno-5-4)  await FirebaseFirestore.addDocument({
[](#%5F%5Fcodelineno-5-5)    reference: 'users',
[](#%5F%5Fcodelineno-5-6)    data: { 
[](#%5F%5Fcodelineno-5-7)      first: 'Alan', 
[](#%5F%5Fcodelineno-5-8)      last: 'Turing', 
[](#%5F%5Fcodelineno-5-9)      born: 1912 
[](#%5F%5Fcodelineno-5-10)    },
[](#%5F%5Fcodelineno-5-11)  });
[](#%5F%5Fcodelineno-5-12)};
[](#%5F%5Fcodelineno-5-13)
[](#%5F%5Fcodelineno-5-14)const setDocument = async () => {
[](#%5F%5Fcodelineno-5-15)  await FirebaseFirestore.setDocument({
[](#%5F%5Fcodelineno-5-16)    reference: 'users/Aorq09lkt1ynbR7xhTUx',
[](#%5F%5Fcodelineno-5-17)    data: { 
[](#%5F%5Fcodelineno-5-18)      first: 'Alan', 
[](#%5F%5Fcodelineno-5-19)      last: 'Turing', 
[](#%5F%5Fcodelineno-5-20)      born: 1912 
[](#%5F%5Fcodelineno-5-21)    },
[](#%5F%5Fcodelineno-5-22)    merge: true,
[](#%5F%5Fcodelineno-5-23)  });
[](#%5F%5Fcodelineno-5-24)};
[](#%5F%5Fcodelineno-5-25)
[](#%5F%5Fcodelineno-5-26)const getDocument = async () => {
[](#%5F%5Fcodelineno-5-27)  const { snapshot } = await FirebaseFirestore.getDocument({
[](#%5F%5Fcodelineno-5-28)    reference: 'users/Aorq09lkt1ynbR7xhTUx',
[](#%5F%5Fcodelineno-5-29)  });
[](#%5F%5Fcodelineno-5-30)  return snapshot;
[](#%5F%5Fcodelineno-5-31)};
[](#%5F%5Fcodelineno-5-32)
[](#%5F%5Fcodelineno-5-33)const updateDocument = async () => {
[](#%5F%5Fcodelineno-5-34)  await FirebaseFirestore.updateDocument({
[](#%5F%5Fcodelineno-5-35)    reference: 'users/Aorq09lkt1ynbR7xhTUx',
[](#%5F%5Fcodelineno-5-36)    data: { 
[](#%5F%5Fcodelineno-5-37)      first: 'Alan', 
[](#%5F%5Fcodelineno-5-38)      last: 'Turing', 
[](#%5F%5Fcodelineno-5-39)      born: 1912 
[](#%5F%5Fcodelineno-5-40)    },
[](#%5F%5Fcodelineno-5-41)  });
[](#%5F%5Fcodelineno-5-42)};
[](#%5F%5Fcodelineno-5-43)
[](#%5F%5Fcodelineno-5-44)const deleteDocument = async () => {
[](#%5F%5Fcodelineno-5-45)  await FirebaseFirestore.deleteDocument({
[](#%5F%5Fcodelineno-5-46)    reference: 'users/Aorq09lkt1ynbR7xhTUx',
[](#%5F%5Fcodelineno-5-47)  });
[](#%5F%5Fcodelineno-5-48)};
[](#%5F%5Fcodelineno-5-49)
[](#%5F%5Fcodelineno-5-50)const writeBatch = async () => {
[](#%5F%5Fcodelineno-5-51)  await FirebaseFirestore.writeBatch({
[](#%5F%5Fcodelineno-5-52)    operations: [
[](#%5F%5Fcodelineno-5-53)      {
[](#%5F%5Fcodelineno-5-54)        type: 'set',
[](#%5F%5Fcodelineno-5-55)        reference: 'users/Aorq09lkt1ynbR7xhTUx',
[](#%5F%5Fcodelineno-5-56)        data: { 
[](#%5F%5Fcodelineno-5-57)          first: 'Alan', 
[](#%5F%5Fcodelineno-5-58)          last: 'Turing', 
[](#%5F%5Fcodelineno-5-59)          born: 1912 
[](#%5F%5Fcodelineno-5-60)        },
[](#%5F%5Fcodelineno-5-61)        options: { merge: true },
[](#%5F%5Fcodelineno-5-62)      },
[](#%5F%5Fcodelineno-5-63)      {
[](#%5F%5Fcodelineno-5-64)        type: 'update',
[](#%5F%5Fcodelineno-5-65)        reference: 'users/Aorq09lkt1ynbR7xhTUx',
[](#%5F%5Fcodelineno-5-66)        data: { 
[](#%5F%5Fcodelineno-5-67)          first: 'Alan', 
[](#%5F%5Fcodelineno-5-68)          last: 'Turing', 
[](#%5F%5Fcodelineno-5-69)          born: 1912 
[](#%5F%5Fcodelineno-5-70)        },
[](#%5F%5Fcodelineno-5-71)      },
[](#%5F%5Fcodelineno-5-72)      {
[](#%5F%5Fcodelineno-5-73)        type: 'delete',
[](#%5F%5Fcodelineno-5-74)        reference: 'users/Aorq09lkt1ynbR7xhTUx',
[](#%5F%5Fcodelineno-5-75)      },
[](#%5F%5Fcodelineno-5-76)    ],
[](#%5F%5Fcodelineno-5-77)  });
[](#%5F%5Fcodelineno-5-78)};
[](#%5F%5Fcodelineno-5-79)
[](#%5F%5Fcodelineno-5-80)const getCollection = async () => {
[](#%5F%5Fcodelineno-5-81)  const { snapshots } = await FirebaseFirestore.getCollection({
[](#%5F%5Fcodelineno-5-82)    reference: 'users',
[](#%5F%5Fcodelineno-5-83)    compositeFilter: {
[](#%5F%5Fcodelineno-5-84)      type: 'and',
[](#%5F%5Fcodelineno-5-85)      queryConstraints: [
[](#%5F%5Fcodelineno-5-86)        {
[](#%5F%5Fcodelineno-5-87)          type: 'where',
[](#%5F%5Fcodelineno-5-88)          fieldPath: 'born',
[](#%5F%5Fcodelineno-5-89)          opStr: '==',
[](#%5F%5Fcodelineno-5-90)          value: 1912,
[](#%5F%5Fcodelineno-5-91)        },
[](#%5F%5Fcodelineno-5-92)      ],
[](#%5F%5Fcodelineno-5-93)    },
[](#%5F%5Fcodelineno-5-94)    queryConstraints: [
[](#%5F%5Fcodelineno-5-95)      {
[](#%5F%5Fcodelineno-5-96)        type: 'orderBy',
[](#%5F%5Fcodelineno-5-97)        fieldPath: 'born',
[](#%5F%5Fcodelineno-5-98)        directionStr: 'desc',
[](#%5F%5Fcodelineno-5-99)      },
[](#%5F%5Fcodelineno-5-100)      {
[](#%5F%5Fcodelineno-5-101)        type: 'limit',
[](#%5F%5Fcodelineno-5-102)        limit: 10,
[](#%5F%5Fcodelineno-5-103)      },
[](#%5F%5Fcodelineno-5-104)    ],
[](#%5F%5Fcodelineno-5-105)  });
[](#%5F%5Fcodelineno-5-106)  return snapshots;
[](#%5F%5Fcodelineno-5-107)};
[](#%5F%5Fcodelineno-5-108)
[](#%5F%5Fcodelineno-5-109)const getCollectionGroup = async () => {
[](#%5F%5Fcodelineno-5-110)  const { snapshots } = await FirebaseFirestore.getCollectionGroup({
[](#%5F%5Fcodelineno-5-111)    reference: 'users',
[](#%5F%5Fcodelineno-5-112)    compositeFilter: {
[](#%5F%5Fcodelineno-5-113)      type: 'and',
[](#%5F%5Fcodelineno-5-114)      queryConstraints: [
[](#%5F%5Fcodelineno-5-115)        {
[](#%5F%5Fcodelineno-5-116)          type: 'where',
[](#%5F%5Fcodelineno-5-117)          fieldPath: 'born',
[](#%5F%5Fcodelineno-5-118)          opStr: '==',
[](#%5F%5Fcodelineno-5-119)          value: 1912,
[](#%5F%5Fcodelineno-5-120)        },
[](#%5F%5Fcodelineno-5-121)      ],
[](#%5F%5Fcodelineno-5-122)    },
[](#%5F%5Fcodelineno-5-123)    queryConstraints: [
[](#%5F%5Fcodelineno-5-124)      {
[](#%5F%5Fcodelineno-5-125)        type: 'orderBy',
[](#%5F%5Fcodelineno-5-126)        fieldPath: 'born',
[](#%5F%5Fcodelineno-5-127)        directionStr: 'desc',
[](#%5F%5Fcodelineno-5-128)      },
[](#%5F%5Fcodelineno-5-129)      {
[](#%5F%5Fcodelineno-5-130)        type: 'limit',
[](#%5F%5Fcodelineno-5-131)        limit: 10,
[](#%5F%5Fcodelineno-5-132)      },
[](#%5F%5Fcodelineno-5-133)    ],
[](#%5F%5Fcodelineno-5-134)  });
[](#%5F%5Fcodelineno-5-135)  return snapshots;
[](#%5F%5Fcodelineno-5-136)};
[](#%5F%5Fcodelineno-5-137)
[](#%5F%5Fcodelineno-5-138)const enableNetwork = async () => {
[](#%5F%5Fcodelineno-5-139)  await FirebaseFirestore.enableNetwork();
[](#%5F%5Fcodelineno-5-140)};
[](#%5F%5Fcodelineno-5-141)
[](#%5F%5Fcodelineno-5-142)const disableNetwork = async () => {
[](#%5F%5Fcodelineno-5-143)  await FirebaseFirestore.disableNetwork();
[](#%5F%5Fcodelineno-5-144)};
[](#%5F%5Fcodelineno-5-145)
[](#%5F%5Fcodelineno-5-146)const useEmulator = async () => {
[](#%5F%5Fcodelineno-5-147)  await FirebaseFirestore.useEmulator({
[](#%5F%5Fcodelineno-5-148)    host: '10.0.2.2',
[](#%5F%5Fcodelineno-5-149)    port: 9001,
[](#%5F%5Fcodelineno-5-150)  });
[](#%5F%5Fcodelineno-5-151)};
[](#%5F%5Fcodelineno-5-152)
[](#%5F%5Fcodelineno-5-153)const addDocumentSnapshotListener = async () => {
[](#%5F%5Fcodelineno-5-154)  const callbackId = await FirebaseFirestore.addDocumentSnapshotListener(
[](#%5F%5Fcodelineno-5-155)    {
[](#%5F%5Fcodelineno-5-156)      reference: 'users/Aorq09lkt1ynbR7xhTUx',
[](#%5F%5Fcodelineno-5-157)    },
[](#%5F%5Fcodelineno-5-158)    (event, error) => {
[](#%5F%5Fcodelineno-5-159)      if (error) {
[](#%5F%5Fcodelineno-5-160)        console.error(error);
[](#%5F%5Fcodelineno-5-161)      } else {
[](#%5F%5Fcodelineno-5-162)        console.log(event);
[](#%5F%5Fcodelineno-5-163)      }
[](#%5F%5Fcodelineno-5-164)    }
[](#%5F%5Fcodelineno-5-165)  );
[](#%5F%5Fcodelineno-5-166)  return callbackId;
[](#%5F%5Fcodelineno-5-167)};
[](#%5F%5Fcodelineno-5-168)
[](#%5F%5Fcodelineno-5-169)const addCollectionSnapshotListener = async () => {
[](#%5F%5Fcodelineno-5-170)  const callbackId = await FirebaseFirestore.addCollectionSnapshotListener(
[](#%5F%5Fcodelineno-5-171)    {
[](#%5F%5Fcodelineno-5-172)      reference: 'users',
[](#%5F%5Fcodelineno-5-173)      compositeFilter: {
[](#%5F%5Fcodelineno-5-174)        type: 'and',
[](#%5F%5Fcodelineno-5-175)        queryConstraints: [
[](#%5F%5Fcodelineno-5-176)          {
[](#%5F%5Fcodelineno-5-177)            type: 'where',
[](#%5F%5Fcodelineno-5-178)            fieldPath: 'born',
[](#%5F%5Fcodelineno-5-179)            opStr: '==',
[](#%5F%5Fcodelineno-5-180)            value: 1912,
[](#%5F%5Fcodelineno-5-181)          },
[](#%5F%5Fcodelineno-5-182)        ],
[](#%5F%5Fcodelineno-5-183)      },
[](#%5F%5Fcodelineno-5-184)      queryConstraints: [
[](#%5F%5Fcodelineno-5-185)        {
[](#%5F%5Fcodelineno-5-186)          type: 'orderBy',
[](#%5F%5Fcodelineno-5-187)          fieldPath: 'born',
[](#%5F%5Fcodelineno-5-188)          directionStr: 'desc',
[](#%5F%5Fcodelineno-5-189)        },
[](#%5F%5Fcodelineno-5-190)        {
[](#%5F%5Fcodelineno-5-191)          type: 'limit',
[](#%5F%5Fcodelineno-5-192)          limit: 10,
[](#%5F%5Fcodelineno-5-193)        },
[](#%5F%5Fcodelineno-5-194)      ],
[](#%5F%5Fcodelineno-5-195)    },
[](#%5F%5Fcodelineno-5-196)    (event, error) => {
[](#%5F%5Fcodelineno-5-197)      if (error) {
[](#%5F%5Fcodelineno-5-198)        console.error(error);
[](#%5F%5Fcodelineno-5-199)      } else {
[](#%5F%5Fcodelineno-5-200)        console.log(event);
[](#%5F%5Fcodelineno-5-201)      }
[](#%5F%5Fcodelineno-5-202)    }
[](#%5F%5Fcodelineno-5-203)  );
[](#%5F%5Fcodelineno-5-204)  return callbackId;
[](#%5F%5Fcodelineno-5-205)};
[](#%5F%5Fcodelineno-5-206)
[](#%5F%5Fcodelineno-5-207)const addCollectionGroupSnapshotListener = async () => {
[](#%5F%5Fcodelineno-5-208)  const callbackId = await FirebaseFirestore.addCollectionGroupSnapshotListener(
[](#%5F%5Fcodelineno-5-209)    {
[](#%5F%5Fcodelineno-5-210)      reference: 'users',
[](#%5F%5Fcodelineno-5-211)      compositeFilter: {
[](#%5F%5Fcodelineno-5-212)        type: 'and',
[](#%5F%5Fcodelineno-5-213)        queryConstraints: [
[](#%5F%5Fcodelineno-5-214)          {
[](#%5F%5Fcodelineno-5-215)            type: 'where',
[](#%5F%5Fcodelineno-5-216)            fieldPath: 'born',
[](#%5F%5Fcodelineno-5-217)            opStr: '==',
[](#%5F%5Fcodelineno-5-218)            value: 1912,
[](#%5F%5Fcodelineno-5-219)          },
[](#%5F%5Fcodelineno-5-220)        ],
[](#%5F%5Fcodelineno-5-221)      },
[](#%5F%5Fcodelineno-5-222)      queryConstraints: [
[](#%5F%5Fcodelineno-5-223)        {
[](#%5F%5Fcodelineno-5-224)          type: 'orderBy',
[](#%5F%5Fcodelineno-5-225)          fieldPath: 'born',
[](#%5F%5Fcodelineno-5-226)          directionStr: 'desc',
[](#%5F%5Fcodelineno-5-227)        },
[](#%5F%5Fcodelineno-5-228)        {
[](#%5F%5Fcodelineno-5-229)          type: 'limit',
[](#%5F%5Fcodelineno-5-230)          limit: 10,
[](#%5F%5Fcodelineno-5-231)        },
[](#%5F%5Fcodelineno-5-232)      ],
[](#%5F%5Fcodelineno-5-233)    },
[](#%5F%5Fcodelineno-5-234)    (event, error) => {
[](#%5F%5Fcodelineno-5-235)      if (error) {
[](#%5F%5Fcodelineno-5-236)        console.error(error);
[](#%5F%5Fcodelineno-5-237)      } else {
[](#%5F%5Fcodelineno-5-238)        console.log(event);
[](#%5F%5Fcodelineno-5-239)      }
[](#%5F%5Fcodelineno-5-240)    }
[](#%5F%5Fcodelineno-5-241)  );
[](#%5F%5Fcodelineno-5-242)  return callbackId;
[](#%5F%5Fcodelineno-5-243)};
[](#%5F%5Fcodelineno-5-244)
[](#%5F%5Fcodelineno-5-245)const removeSnapshotListener = async (callbackId: string) => {
[](#%5F%5Fcodelineno-5-246)  await FirebaseFirestore.removeSnapshotListener({
[](#%5F%5Fcodelineno-5-247)    callbackId,
[](#%5F%5Fcodelineno-5-248)  });
[](#%5F%5Fcodelineno-5-249)};
[](#%5F%5Fcodelineno-5-250)
[](#%5F%5Fcodelineno-5-251)const removeAllListeners = async () => {
[](#%5F%5Fcodelineno-5-252)  await FirebaseFirestore.removeAllListeners();
[](#%5F%5Fcodelineno-5-253)};
`

## API[¶](#api "Permanent link")

* [addDocument(...)](#adddocument)
* [addCollectionGroupSnapshotListener(...)](#addcollectiongroupsnapshotlistener)
* [addCollectionSnapshotListener(...)](#addcollectionsnapshotlistener)
* [addDocumentSnapshotListener(...)](#adddocumentsnapshotlistener)
* [clearPersistence()](#clearpersistence)
* [deleteDocument(...)](#deletedocument)
* [disableNetwork()](#disablenetwork)
* [disablePersistence()](#disablepersistence)
* [enablePersistence(...)](#enablepersistence)
* [enableNetwork()](#enablenetwork)
* [getCollection(...)](#getcollection)
* [getCollectionGroup(...)](#getcollectiongroup)
* [getCountFromServer(...)](#getcountfromserver)
* [getDocument(...)](#getdocument)
* [removeAllListeners()](#removealllisteners)
* [removeSnapshotListener(...)](#removesnapshotlistener)
* [setDocument(...)](#setdocument)
* [updateDocument(...)](#updatedocument)
* [useEmulator(...)](#useemulator)
* [writeBatch(...)](#writebatch)
* [Interfaces](#interfaces)
* [Type Aliases](#type-aliases)

### addDocument(...)[¶](#adddocument "Permanent link")

`[](#%5F%5Fcodelineno-6-1)addDocument(options: AddDocumentOptions) => Promise<AddDocumentResult>
`

Adds a new document to a collection with the given data.

| Param       | Type                                      |
| ----------- | ----------------------------------------- |
| **options** | [AddDocumentOptions](#adddocumentoptions) |

**Returns:** `Promise<[AddDocumentResult](#adddocumentresult)>`

**Since:** 5.2.0

---

### addCollectionGroupSnapshotListener(...)[¶](#addcollectiongroupsnapshotlistener "Permanent link")

`[](#%5F%5Fcodelineno-7-1)addCollectionGroupSnapshotListener<T extends DocumentData = DocumentData>(options: AddCollectionGroupSnapshotListenerOptions, callback: AddCollectionGroupSnapshotListenerCallback<T>) => Promise<CallbackId>
`

Adds a listener for collection group snapshot events.

| Param        | Type                                                                                         |
| ------------ | -------------------------------------------------------------------------------------------- |
| **options**  | [AddCollectionGroupSnapshotListenerOptions](#addcollectiongroupsnapshotlisteneroptions)      |
| **callback** | [AddCollectionGroupSnapshotListenerCallback](#addcollectiongroupsnapshotlistenercallback)<T> |

**Returns:** `Promise<string>`

**Since:** 6.1.0

---

### addCollectionSnapshotListener(...)[¶](#addcollectionsnapshotlistener "Permanent link")

`[](#%5F%5Fcodelineno-8-1)addCollectionSnapshotListener<T extends DocumentData = DocumentData>(options: AddCollectionSnapshotListenerOptions, callback: AddCollectionSnapshotListenerCallback<T>) => Promise<CallbackId>
`

Adds a listener for collection snapshot events.

| Param        | Type                                                                               |
| ------------ | ---------------------------------------------------------------------------------- |
| **options**  | [AddCollectionSnapshotListenerOptions](#addcollectionsnapshotlisteneroptions)      |
| **callback** | [AddCollectionSnapshotListenerCallback](#addcollectionsnapshotlistenercallback)<T> |

**Returns:** `Promise<string>`

**Since:** 5.2.0

---

### addDocumentSnapshotListener(...)[¶](#adddocumentsnapshotlistener "Permanent link")

`[](#%5F%5Fcodelineno-9-1)addDocumentSnapshotListener<T extends DocumentData = DocumentData>(options: AddDocumentSnapshotListenerOptions, callback: AddDocumentSnapshotListenerCallback<T>) => Promise<CallbackId>
`

Adds a listener for document snapshot events.

| Param        | Type                                                                           |
| ------------ | ------------------------------------------------------------------------------ |
| **options**  | [AddDocumentSnapshotListenerOptions](#adddocumentsnapshotlisteneroptions)      |
| **callback** | [AddDocumentSnapshotListenerCallback](#adddocumentsnapshotlistenercallback)<T> |

**Returns:** `Promise<string>`

**Since:** 5.2.0

---

### clearPersistence()[¶](#clearpersistence "Permanent link")

`[](#%5F%5Fcodelineno-10-1)clearPersistence() => Promise<void>
`

Clears the persistent storage. This includes pending writes and cached documents.

**Attention**: Must be called after the app is shutdown or when the app is first initialized.

**Since:** 5.2.0

---

### deleteDocument(...)[¶](#deletedocument "Permanent link")

`[](#%5F%5Fcodelineno-11-1)deleteDocument(options: DeleteDocumentOptions) => Promise<void>
`

Deletes the document referred to by the specified reference.

| Param       | Type                                            |
| ----------- | ----------------------------------------------- |
| **options** | [DeleteDocumentOptions](#deletedocumentoptions) |

**Since:** 5.2.0

---

### disableNetwork()[¶](#disablenetwork "Permanent link")

`[](#%5F%5Fcodelineno-12-1)disableNetwork() => Promise<void>
`

Disables use of the network.

**Since:** 5.2.0

---

### disablePersistence()[¶](#disablepersistence "Permanent link")

`[](#%5F%5Fcodelineno-13-1)disablePersistence() => Promise<void>
`

Disables offline persistence.

**Attention**: Must be called before any other Firestore method.

**Since:** 8.2.0

---

### enablePersistence(...)[¶](#enablepersistence "Permanent link")

`[](#%5F%5Fcodelineno-14-1)enablePersistence(options?: EnablePersistenceOptions | undefined) => Promise<void>
`

Enables offline persistence.

**Attention**: Must be called before any other Firestore method.

| Param       | Type                                                  |
| ----------- | ----------------------------------------------------- |
| **options** | [EnablePersistenceOptions](#enablepersistenceoptions) |

**Since:** 8.2.0

---

### enableNetwork()[¶](#enablenetwork "Permanent link")

`[](#%5F%5Fcodelineno-15-1)enableNetwork() => Promise<void>
`

Re-enables use of the network.

**Since:** 5.2.0

---

### getCollection(...)[¶](#getcollection "Permanent link")

`[](#%5F%5Fcodelineno-16-1)getCollection<T extends DocumentData = DocumentData>(options: GetCollectionOptions) => Promise<GetCollectionResult<T>>
`

Reads the collection referenced by the specified reference.

| Param       | Type                                          |
| ----------- | --------------------------------------------- |
| **options** | [GetCollectionOptions](#getcollectionoptions) |

**Returns:** `Promise<[GetCollectionResult](#getcollectionresult)<T>>`

**Since:** 5.2.0

---

### getCollectionGroup(...)[¶](#getcollectiongroup "Permanent link")

`[](#%5F%5Fcodelineno-17-1)getCollectionGroup<T extends DocumentData = DocumentData>(options: GetCollectionGroupOptions) => Promise<GetCollectionGroupResult<T>>
`

Reads the collection group referenced by the specified reference.

| Param       | Type                                                    |
| ----------- | ------------------------------------------------------- |
| **options** | [GetCollectionGroupOptions](#getcollectiongroupoptions) |

**Returns:** `Promise<[GetCollectionGroupResult](#getcollectiongroupresult)<T>>`

---

### getCountFromServer(...)[¶](#getcountfromserver "Permanent link")

`[](#%5F%5Fcodelineno-18-1)getCountFromServer(options: GetCountFromServerOptions) => Promise<GetCountFromServerResult>
`

Fetches the number of documents in a collection.

| Param       | Type                                                    |
| ----------- | ------------------------------------------------------- |
| **options** | [GetCountFromServerOptions](#getcountfromserveroptions) |

**Returns:** `Promise<[GetCountFromServerResult](#getcountfromserverresult)>`

**Since:** 6.4.0

---

### getDocument(...)[¶](#getdocument "Permanent link")

`[](#%5F%5Fcodelineno-19-1)getDocument<T extends DocumentData = DocumentData>(options: GetDocumentOptions) => Promise<GetDocumentResult<T>>
`

Reads the document referred to by the specified reference.

| Param       | Type                                      |
| ----------- | ----------------------------------------- |
| **options** | [GetDocumentOptions](#getdocumentoptions) |

**Returns:** `Promise<[GetDocumentResult](#getdocumentresult)<T>>`

**Since:** 5.2.0

---

### removeAllListeners()[¶](#removealllisteners "Permanent link")

`[](#%5F%5Fcodelineno-20-1)removeAllListeners() => Promise<void>
`

Remove all listeners for this plugin.

**Since:** 5.2.0

---

### removeSnapshotListener(...)[¶](#removesnapshotlistener "Permanent link")

`[](#%5F%5Fcodelineno-21-1)removeSnapshotListener(options: RemoveSnapshotListenerOptions) => Promise<void>
`

Remove a listener for document or collection snapshot events.

| Param       | Type                                                            |
| ----------- | --------------------------------------------------------------- |
| **options** | [RemoveSnapshotListenerOptions](#removesnapshotlisteneroptions) |

**Since:** 5.2.0

---

### setDocument(...)[¶](#setdocument "Permanent link")

`[](#%5F%5Fcodelineno-22-1)setDocument(options: SetDocumentOptions) => Promise<void>
`

Writes to the document referred to by the specified reference. If the document does not yet exist, it will be created.

| Param       | Type                                      |
| ----------- | ----------------------------------------- |
| **options** | [SetDocumentOptions](#setdocumentoptions) |

**Since:** 5.2.0

---

### updateDocument(...)[¶](#updatedocument "Permanent link")

`[](#%5F%5Fcodelineno-23-1)updateDocument(options: UpdateDocumentOptions) => Promise<void>
`

Updates fields in the document referred to by the specified reference.

| Param       | Type                                            |
| ----------- | ----------------------------------------------- |
| **options** | [UpdateDocumentOptions](#updatedocumentoptions) |

**Since:** 5.2.0

---

### useEmulator(...)[¶](#useemulator "Permanent link")

`[](#%5F%5Fcodelineno-24-1)useEmulator(options: UseEmulatorOptions) => Promise<void>
`

Instrument your app to talk to the Firestore emulator.

| Param       | Type                                      |
| ----------- | ----------------------------------------- |
| **options** | [UseEmulatorOptions](#useemulatoroptions) |

**Since:** 6.1.0

---

### writeBatch(...)[¶](#writebatch "Permanent link")

`[](#%5F%5Fcodelineno-25-1)writeBatch(options: WriteBatchOptions) => Promise<void>
`

Execute multiple write operations as a single batch.

| Param       | Type                                    |
| ----------- | --------------------------------------- |
| **options** | [WriteBatchOptions](#writebatchoptions) |

**Since:** 6.1.0

---

### Interfaces[¶](#interfaces "Permanent link")

#### AddDocumentResult[¶](#adddocumentresult "Permanent link")

| Prop          | Type                                    | Description                                | Since |
| ------------- | --------------------------------------- | ------------------------------------------ | ----- |
| **reference** | [DocumentReference](#documentreference) | The reference of the newly added document. | 5.2.0 |

#### DocumentReference[¶](#documentreference "Permanent link")

| Prop     | Type   | Description                                      | Since |
| -------- | ------ | ------------------------------------------------ | ----- |
| **id**   | string | The document's identifier within its collection. | 5.2.0 |
| **path** | string | The path of the document.                        | 5.2.0 |

#### AddDocumentOptions[¶](#adddocumentoptions "Permanent link")

| Prop          | Type                          | Description                                                                       | Since |
| ------------- | ----------------------------- | --------------------------------------------------------------------------------- | ----- |
| **reference** | string                        | The reference as a string, with path components separated by a forward slash (/). | 5.2.0 |
| **data**      | [DocumentData](#documentdata) | An object containing the data for the new document.                               | 5.2.0 |

#### DocumentData[¶](#documentdata "Permanent link")

#### AddCollectionGroupSnapshotListenerOptions[¶](#addcollectiongroupsnapshotlisteneroptions "Permanent link")

| Prop                 | Type                                                              | Description                                                                                         | Since |
| -------------------- | ----------------------------------------------------------------- | --------------------------------------------------------------------------------------------------- | ----- |
| **reference**        | string                                                            | The reference as a string, with path components separated by a forward slash (/).                   | 6.1.0 |
| **compositeFilter**  | [QueryCompositeFilterConstraint](#querycompositefilterconstraint) | The filter to apply.                                                                                | 6.1.0 |
| **queryConstraints** | QueryNonFilterConstraint\[\]                                      | Narrow or order the set of documents to retrieve, but do not explicitly filter for document fields. | 6.1.0 |

#### QueryCompositeFilterConstraint[¶](#querycompositefilterconstraint "Permanent link")

| Prop                 | Type                      | Description                 | Since |
| -------------------- | ------------------------- | --------------------------- | ----- |
| **type**             | 'and' \| 'or'             | The type of the constraint. | 5.2.0 |
| **queryConstraints** | QueryFilterConstraint\[\] | The filters to apply.       | 5.2.0 |

#### QueryFieldFilterConstraint[¶](#queryfieldfilterconstraint "Permanent link")

| Prop          | Type                            | Description                    | Since |
| ------------- | ------------------------------- | ------------------------------ | ----- |
| **type**      | 'where'                         | The type of the constraint.    | 5.2.0 |
| **fieldPath** | string                          | The path to compare.           | 5.2.0 |
| **opStr**     | [QueryOperator](#queryoperator) | The operation string to apply. | 5.2.0 |
| **value**     | any                             | The value for comparison.      | 5.2.0 |

#### QueryOrderByConstraint[¶](#queryorderbyconstraint "Permanent link")

| Prop             | Type                                  | Description                 | Since |
| ---------------- | ------------------------------------- | --------------------------- | ----- |
| **type**         | 'orderBy'                             | The type of the constraint. | 5.2.0 |
| **fieldPath**    | string                                | The path to compare.        | 5.2.0 |
| **directionStr** | [OrderByDirection](#orderbydirection) | The direction to sort by.   | 5.2.0 |

#### QueryLimitConstraint[¶](#querylimitconstraint "Permanent link")

| Prop      | Type                     | Description                            | Since |
| --------- | ------------------------ | -------------------------------------- | ----- |
| **type**  | 'limit' \| 'limitToLast' | The type of the constraint.            | 5.2.0 |
| **limit** | number                   | The maximum number of items to return. | 5.2.0 |

#### QueryStartAtConstraint[¶](#querystartatconstraint "Permanent link")

| Prop          | Type                      | Description                                                                                                                                                      | Since |
| ------------- | ------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----- |
| **type**      | 'startAt' \| 'startAfter' | The type of the constraint.                                                                                                                                      | 5.2.0 |
| **reference** | string                    | The reference to start at or after as a string, with path components separated by a forward slash (/). **Attention**: This requires an additional document read. | 5.2.0 |

#### QueryEndAtConstraint[¶](#queryendatconstraint "Permanent link")

| Prop          | Type                   | Description                                                                                                                                                        | Since |
| ------------- | ---------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ----- |
| **type**      | 'endAt' \| 'endBefore' | The type of the constraint.                                                                                                                                        | 5.2.0 |
| **reference** | string                 | The reference as to end at or before as a string, with path components separated by a forward slash (/). **Attention**: This requires an additional document read. | 5.2.0 |

#### GetCollectionGroupResult[¶](#getcollectiongroupresult "Permanent link")

| Prop          | Type                                         | Description                      | Since |
| ------------- | -------------------------------------------- | -------------------------------- | ----- |
| **snapshots** | [DocumentSnapshot](#documentsnapshot)<T>\[\] | The documents in the collection. | 5.2.0 |

#### DocumentSnapshot[¶](#documentsnapshot "Permanent link")

| Prop         | Type                                  | Description                                                                                 | Since |
| ------------ | ------------------------------------- | ------------------------------------------------------------------------------------------- | ----- |
| **id**       | string                                | The document's identifier within its collection.                                            | 5.2.0 |
| **path**     | string                                | The path of the document.                                                                   | 5.2.0 |
| **data**     | T \| null                             | An object containing the data for the document. Returns null if the document doesn't exist. | 5.2.0 |
| **metadata** | [SnapshotMetadata](#snapshotmetadata) | Metadata about the snapshot, concerning its source and if it has local modifications.       | 6.2.0 |

#### SnapshotMetadata[¶](#snapshotmetadata "Permanent link")

| Prop                 | Type    | Description                                               | Since |
| -------------------- | ------- | --------------------------------------------------------- | ----- |
| **fromCache**        | boolean | True if the snapshot was created from cached data.        | 6.2.0 |
| **hasPendingWrites** | boolean | True if the snapshot was created from pending write data. | 6.2.0 |

#### AddCollectionSnapshotListenerOptions[¶](#addcollectionsnapshotlisteneroptions "Permanent link")

| Prop                 | Type                                                              | Description                                                                                         | Since |
| -------------------- | ----------------------------------------------------------------- | --------------------------------------------------------------------------------------------------- | ----- |
| **reference**        | string                                                            | The reference as a string, with path components separated by a forward slash (/).                   | 5.2.0 |
| **compositeFilter**  | [QueryCompositeFilterConstraint](#querycompositefilterconstraint) | The filter to apply.                                                                                | 5.2.0 |
| **queryConstraints** | QueryNonFilterConstraint\[\]                                      | Narrow or order the set of documents to retrieve, but do not explicitly filter for document fields. | 5.2.0 |

#### GetCollectionResult[¶](#getcollectionresult "Permanent link")

| Prop          | Type                                         | Description                      | Since |
| ------------- | -------------------------------------------- | -------------------------------- | ----- |
| **snapshots** | [DocumentSnapshot](#documentsnapshot)<T>\[\] | The documents in the collection. | 5.2.0 |

#### AddDocumentSnapshotListenerOptions[¶](#adddocumentsnapshotlisteneroptions "Permanent link")

| Prop          | Type   | Description                                                                       | Since |
| ------------- | ------ | --------------------------------------------------------------------------------- | ----- |
| **reference** | string | The reference as a string, with path components separated by a forward slash (/). | 5.2.0 |

#### GetDocumentResult[¶](#getdocumentresult "Permanent link")

| Prop         | Type                                     | Description                    | Since |
| ------------ | ---------------------------------------- | ------------------------------ | ----- |
| **snapshot** | [DocumentSnapshot](#documentsnapshot)<T> | The current document contents. | 5.2.0 |

#### DeleteDocumentOptions[¶](#deletedocumentoptions "Permanent link")

| Prop          | Type   | Description                                                                       | Since |
| ------------- | ------ | --------------------------------------------------------------------------------- | ----- |
| **reference** | string | The reference as a string, with path components separated by a forward slash (/). | 5.2.0 |

#### EnablePersistenceOptions[¶](#enablepersistenceoptions "Permanent link")

| Prop                | Type    | Description                                                                      | Default            | Since |
| ------------------- | ------- | -------------------------------------------------------------------------------- | ------------------ | ----- |
| **cacheSizeBytes**  | number  | The cache size in bytes.                                                         | 104857600 (100 MB) | 8.2.0 |
| **synchronizeTabs** | boolean | Whether to synchronize persistence across multiple tabs. Only available for Web. | false              | 8.2.0 |

#### GetCollectionOptions[¶](#getcollectionoptions "Permanent link")

| Prop                 | Type                                                              | Description                                                                                         | Since |
| -------------------- | ----------------------------------------------------------------- | --------------------------------------------------------------------------------------------------- | ----- |
| **reference**        | string                                                            | The reference as a string, with path components separated by a forward slash (/).                   | 5.2.0 |
| **compositeFilter**  | [QueryCompositeFilterConstraint](#querycompositefilterconstraint) | The filter to apply.                                                                                | 5.2.0 |
| **queryConstraints** | QueryNonFilterConstraint\[\]                                      | Narrow or order the set of documents to retrieve, but do not explicitly filter for document fields. | 5.2.0 |

#### GetCollectionGroupOptions[¶](#getcollectiongroupoptions "Permanent link")

| Prop                 | Type                                                              | Description                                                                                         | Since |
| -------------------- | ----------------------------------------------------------------- | --------------------------------------------------------------------------------------------------- | ----- |
| **reference**        | string                                                            | The reference as a string, with path components separated by a forward slash (/).                   | 5.2.0 |
| **compositeFilter**  | [QueryCompositeFilterConstraint](#querycompositefilterconstraint) | The filter to apply.                                                                                | 5.2.0 |
| **queryConstraints** | QueryNonFilterConstraint\[\]                                      | Narrow or order the set of documents to retrieve, but do not explicitly filter for document fields. | 5.2.0 |

#### GetCountFromServerResult[¶](#getcountfromserverresult "Permanent link")

| Prop      | Type   | Description                                | Since |
| --------- | ------ | ------------------------------------------ | ----- |
| **count** | number | The number of documents in the collection. | 6.4.0 |

#### GetCountFromServerOptions[¶](#getcountfromserveroptions "Permanent link")

| Prop          | Type   | Description                                                                       | Since |
| ------------- | ------ | --------------------------------------------------------------------------------- | ----- |
| **reference** | string | The reference as a string, with path components separated by a forward slash (/). | 6.4.0 |

#### GetDocumentOptions[¶](#getdocumentoptions "Permanent link")

| Prop          | Type   | Description                                                                       | Since |
| ------------- | ------ | --------------------------------------------------------------------------------- | ----- |
| **reference** | string | The reference as a string, with path components separated by a forward slash (/). | 5.2.0 |

#### RemoveSnapshotListenerOptions[¶](#removesnapshotlisteneroptions "Permanent link")

| Prop           | Type                      | Since |
| -------------- | ------------------------- | ----- |
| **callbackId** | [CallbackId](#callbackid) | 5.2.0 |

#### SetDocumentOptions[¶](#setdocumentoptions "Permanent link")

| Prop          | Type                          | Description                                                                       | Default | Since |
| ------------- | ----------------------------- | --------------------------------------------------------------------------------- | ------- | ----- |
| **reference** | string                        | The reference as a string, with path components separated by a forward slash (/). | 5.2.0   |       |
| **data**      | [DocumentData](#documentdata) | An object containing the data for the new document.                               | 5.2.0   |       |
| **merge**     | boolean                       | Whether to merge the provided data with an existing document.                     | false   | 5.2.0 |

#### UpdateDocumentOptions[¶](#updatedocumentoptions "Permanent link")

| Prop          | Type                          | Description                                                                       | Since |
| ------------- | ----------------------------- | --------------------------------------------------------------------------------- | ----- |
| **reference** | string                        | The reference as a string, with path components separated by a forward slash (/). | 5.2.0 |
| **data**      | [DocumentData](#documentdata) | An object containing the data for the new document.                               | 5.2.0 |

#### UseEmulatorOptions[¶](#useemulatoroptions "Permanent link")

| Prop     | Type   | Description                                                                                                                                                                     | Default | Since |
| -------- | ------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------- | ----- |
| **host** | string | The emulator host without any port or scheme. Note when using a Android Emulator device: 10.0.2.2 is the special IP address to connect to the 'localhost' of the host computer. | 6.1.0   |       |
| **port** | number | The emulator port.                                                                                                                                                              | 8080    | 6.1.0 |

#### WriteBatchOptions[¶](#writebatchoptions "Permanent link")

| Prop           | Type                    | Description                             | Since |
| -------------- | ----------------------- | --------------------------------------- | ----- |
| **operations** | WriteBatchOperation\[\] | The operations to execute in the batch. | 6.1.0 |

#### WriteBatchOperation[¶](#writebatchoperation "Permanent link")

| Prop          | Type                          | Description                                                                       | Since                  |       |
| ------------- | ----------------------------- | --------------------------------------------------------------------------------- | ---------------------- | ----- |
| **type**      | 'set' \| 'update'             | 'delete'                                                                          | The type of operation. | 6.1.0 |
| **reference** | string                        | The reference as a string, with path components separated by a forward slash (/). | 6.1.0                  |       |
| **data**      | [DocumentData](#documentdata) | An object containing the data for the new document.                               | 6.1.0                  |       |
| **options**   | [SetOptions](#setoptions)     | An object to configure the set behavior.                                          | 7.3.0                  |       |

#### SetOptions[¶](#setoptions "Permanent link")

| Prop      | Type    | Description                                                                | Default | Since |
| --------- | ------- | -------------------------------------------------------------------------- | ------- | ----- |
| **merge** | boolean | Whether a merge should be performed or the document should be overwritten. | false   | 7.3.0 |

### Type Aliases[¶](#type-aliases "Permanent link")

#### QueryFilterConstraint[¶](#queryfilterconstraint "Permanent link")

`[QueryFieldFilterConstraint](#queryfieldfilterconstraint) | [QueryCompositeFilterConstraint](#querycompositefilterconstraint)`

#### QueryOperator[¶](#queryoperator "Permanent link")

`'<' | '<=' | '==' | '>=' | '>' | '!=' | 'array-contains' | 'array-contains-any' | 'in' | 'not-in'`

#### QueryNonFilterConstraint[¶](#querynonfilterconstraint "Permanent link")

`[QueryOrderByConstraint](#queryorderbyconstraint) | [QueryLimitConstraint](#querylimitconstraint) | [QueryStartAtConstraint](#querystartatconstraint) | [QueryEndAtConstraint](#queryendatconstraint)`

#### OrderByDirection[¶](#orderbydirection "Permanent link")

`'desc' | 'asc'`

#### AddCollectionGroupSnapshotListenerCallback[¶](#addcollectiongroupsnapshotlistenercallback "Permanent link")

`(event: [AddCollectionGroupSnapshotListenerCallbackEvent](#addcollectiongroupsnapshotlistenercallbackevent)<T> | null, error: any): void`

#### AddCollectionGroupSnapshotListenerCallbackEvent[¶](#addcollectiongroupsnapshotlistenercallbackevent "Permanent link")

`[GetCollectionGroupResult](#getcollectiongroupresult)<T>`

#### CallbackId[¶](#callbackid "Permanent link")

`string`

#### AddCollectionSnapshotListenerCallback[¶](#addcollectionsnapshotlistenercallback "Permanent link")

`(event: [AddCollectionSnapshotListenerCallbackEvent](#addcollectionsnapshotlistenercallbackevent)<T> | null, error: any): void`

#### AddCollectionSnapshotListenerCallbackEvent[¶](#addcollectionsnapshotlistenercallbackevent "Permanent link")

`[GetCollectionResult](#getcollectionresult)<T>`

#### AddDocumentSnapshotListenerCallback[¶](#adddocumentsnapshotlistenercallback "Permanent link")

`(event: [AddDocumentSnapshotListenerCallbackEvent](#adddocumentsnapshotlistenercallbackevent)<T> | null, error: any): void`

#### AddDocumentSnapshotListenerCallbackEvent[¶](#adddocumentsnapshotlistenercallbackevent "Permanent link")

`[GetDocumentResult](#getdocumentresult)<T>`

## Changelog[¶](#changelog "Permanent link")

See [CHANGELOG.md](https://github.com/capawesome-team/capacitor-firebase/blob/main/packages/firestore/CHANGELOG.md).

## License[¶](#license "Permanent link")

See [LICENSE](https://github.com/capawesome-team/capacitor-firebase/blob/main/packages/firestore/LICENSE).

---

1. This project is not affiliated with, endorsed by, sponsored by, or approved by Google LLC or any of their affiliates or subsidiaries. [↩](#fnref:1 "Jump back to footnote 1 in the text")

May 17, 2026 

 Back to top 