Registry / database / firebase-rest-firestore

firebase-rest-firestore

JSON →
library1.6.0jsnpmunverified

Firebase REST Firestore is a lightweight Firestore REST API client optimized for Edge runtime environments such as Cloudflare Workers and Vercel Edge Functions, where the Firebase Admin SDK cannot run. Version 1.6.0 offers full CRUD operations, TypeScript support, token caching, and an intuitive API with explicit configuration. It differentiates itself by avoiding hidden environment variable dependencies and supporting FieldValue sentinels like serverTimestamp. Released under MIT license, it requires Node.js >=20.8.1.

database
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

The package is ESM-only; CommonJS require is not supported.

import { createFirestoreClient } from 'firebase-rest-firestore'

The FirestoreClient class is exported as a named export. It is primarily used for type annotations.

import { FirestoreClient } from 'firebase-rest-firestore'

FieldValue is a named export providing sentinels like serverTimestamp().

import { FieldValue } from 'firebase-rest-firestore'

The package does not have a default export; use namespace import if needed.

import * as FirebaseRestFirestore from 'firebase-rest-firestore'

Shows creating a client, adding a document with server timestamp, retrieving by ID, and querying with a filter.

import { createFirestoreClient, FieldValue } from 'firebase-rest-firestore'; const firestore = createFirestoreClient({ projectId: process.env.FIREBASE_PROJECT_ID ?? '', privateKey: (process.env.FIREBASE_PRIVATE_KEY ?? '').replace(/\\n/g, '\n'), clientEmail: process.env.FIREBASE_CLIENT_EMAIL ?? '', }); async function main() { const doc = await firestore.add('users', { name: 'Alice', createdAt: FieldValue.serverTimestamp(), }); console.log('Created document:', doc.id); const retrieved = await firestore.get('users', doc.id); console.log('Retrieved:', retrieved); const results = await firestore .collection('users') .where('name', '==', 'Alice') .get(); console.log('Query count:', results.size); } main().catch(console.error);
Debug
Known footguns
gotchaPrivate key must have literal newlines replaced with actual newlines; environment variables often strip newlines.
breakingRequires Node.js >=20.8.1; older versions (e.g., Node 18) will throw runtime errors.
deprecatedThe add() method returns the created document directly (not a DocumentReference) in v1.6.0.
gotchaThe update() method does not support FieldValue.increment() or array operations in this version.
gotchaQueries using collection(...).where() return a QuerySnapshot; you must call .get() to execute.
Upgrade
Version history

Breaking-change detection hasn't run for this library yet.

Audit
Security & dependencies

CVE tracking and dependency tree are planned for a later release.

Agent activity
9 hits · last 30 days
gptbot
3
mj12bot
1
Resources