> ## Documentation Index
> Fetch the complete documentation index at: https://docs.bijection.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Google Cloud Firestore

> List a collection or watch a fixed document target in Firestore.

## List a collection

Mount [`@bijectionhq/app-rest`](https://docs.bijection.com/integrations/native-rest#mount-and-bind) once
per collection. The full resource name may identify a top-level collection or a
collection under a specific parent document. Use letters, digits, underscores
and hyphens for collection and parent document segments.

```ts theme={"theme":{"light":"github-light-default","dark":"github-dark-default"}}
const selection = "projects/my-project/databases/(default)/documents/inventory";
const provider = providerEndpoint(
  "firestore.collection.observations", "https://firestore.googleapis.com",
  `/v1/${selection}`, { kind: "bearer", secret: accessToken }, data,
);
```

Seal a Google access token with `datastore` or `cloud-platform` OAuth scope
and Firestore read permissions. Rotate the token by setting its secret again. Pass `provider` as `receivers.provider`, and the same label to the binder and as the app's `data`.

```ts theme={"theme":{"light":"github-light-default","dark":"github-dark-default"}}
{ profile: { mode: "provider", provider: "firestore.collection.observations", selection, limit: 16 } }
```

Documents land as typed Firestore JSON keyed by full resource name, at most
512 characters. Each page carries up to 32 documents and 36 KiB. The
collection's opaque page token continues traversal in name order. For a
finite read at one instant supply `start` as a UTC Firestore `readTime`
within the database's retention limits. Otherwise each sweep restarts after
the final page and can observe concurrent edits. Missing documents remain.

[Firestore ListDocuments API](https://docs.cloud.google.com/firestore/docs/reference/rest/v1/projects.databases.documents/listDocuments)

## Listen to named documents

Mount `@bijectionhq/app-documents` once per fixed target of one to eight
named documents. Follow the [Google stream mount example](https://docs.bijection.com/integrations/native-bigtable#mount-a-google-stream),
use `firestoreListen(credential, data)` from that package,
and bind it to the Documents app's `provider`. The receiver binder and the app's `data` take the same label.

Seal a Google access token and the exact target in the receiver
credential. Grant Firestore read access and use the `datastore` or
`cloud-platform` scope. List full, distinct document names in ascending
order. Each can have up to 384 characters.

```json theme={"theme":{"light":"github-light-default","dark":"github-dark-default"}}
{
  "accessToken": "GOOGLE_ACCESS_TOKEN",
  "scope": {
    "provider": "firestore",
    "database": "projects/my-project/databases/(default)",
    "documents": [
      "projects/my-project/databases/(default)/documents/inventory/widget"
    ]
  }
}
```

```ts theme={"theme":{"light":"github-light-default","dark":"github-dark-default"}}
{
  selection: { mode: "firestore.listen", terms: {
    database: "projects/my-project/databases/(default)",
    documents: [
      "projects/my-project/databases/(default)/documents/inventory/widget",
    ],
  } },
}
```

Each pass sends one AddTarget and keeps the request side open while
receiving Firestore's bidirectional stream. It closes at the first
consistent snapshot with a resume token or at its 20-second deadline.
The app commits the token, read time and membership with its document
changes. A resumed pass without new data can leave the position unchanged.

Documents land as base64 Firestore Document Protobuf under their full
names. Deletes and target removals clear the projected document. The
first consistent snapshot also clears absent names within the fixed
target. A reset, invalid retained token or existence-count mismatch can
record a continuity gap for operator review. A pass accepts up to 48 KiB
of answer data within the action result's encoded bound. Oversized contents
hold the previous token. Collection queries use the collection listing
mode above.

[Firestore Listen protocol](https://github.com/googleapis/googleapis/blob/master/google/firestore/v1/firestore.proto)


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.