FirestoreProviderclass

new FirestoreProvider<I, T>(options: FirestoreProviderOptions)
ParamType
optionsFirestoreProviderOptions
Options for FirestoreProvider. required
    .projectstring
Google Cloud project id. required readonly
    .databasestring
Firestore database id. Defaults to "(default)" readonly
    .hoststring
Base URL of the Firestore API, e.g. "http://127.0.0.1:8080" for the Firestore emulator. Defaults to "https://firestore.googleapis.com" readonly
    .token(() => string
PromiseLike<string>)
Return an OAuth2 access token for each request, e.g. from google-auth-library or a hand-rolled service-account JWT exchange.
- Omit to send no Authorization header (correct for the Firestore emulator). readonly
    .fetch((input: string, init: RequestInit) => Promise<Response>)
Fetch implementation to use for requests (defaults to the global fetch). readonly
Return
FirestoreProvider<I, T>
Cloud Firestore database provider that talks to the Firestore REST API using fetch, implementing the DBProvider abstraction.

Cloud Firestore database provider that talks to the Firestore REST API using fetch, implementing the DBProvider abstraction.

  • Zero dependencies, so it runs anywhere fetch runs: Node.js, Bun, Cloudflare Workers, Deno, and other edge runtimes.
  • Supports transactions via transact() — reads see a consistent snapshot, writes buffer and commit atomically, and contended commits retry.
  • Does not support realtime subscriptions: getItemSequence() and getQuerySequence() throw UnsupportedError (the :listen endpoint requires a streaming session the plain REST API cannot provide).
  • Data read from Firestore is unvalidated — wrap in ValidationDBProvider to guarantee types.

Examples

const provider = new FirestoreProvider({ project: "my-project", token: () => auth.getAccessToken() });
 const id = await provider.addItem(users, { name: "Dave" });