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.

npm install firebase-rest-firestore
INSTALL
IMPORT
SIG · FIREBASE-REST-FIRE
F
firebase-rest-firestore
databasejavascriptv1.6.0
harness data pending
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.

createFirestoreClient
✓ import { createFirestoreClient } from 'firebase-rest-firestore'
✗ const createFirestoreClient = require('firebase-rest-firestore')
The package is ESM-only; CommonJS require is not supported.
FirestoreClient
✓ import { FirestoreClient } from 'firebase-rest-firestore'
The FirestoreClient class is exported as a named export. It is primarily used for type annotations.
FieldValue
✓ import { FieldValue } from 'firebase-rest-firestore'
FieldValue is a named export providing sentinels like serverTimestamp().
default import
✓ import * as FirebaseRestFirestore from 'firebase-rest-firestore'
✗ import FirebaseRestFirestore from 'firebase-rest-firestore'
The package does not have a default export; use namespace import if needed.

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 issues
gotchaPrivate key must have literal newlines replaced with actual newlines; environment variables often strip newlines.
fix
Use .replace(/\\n/g, '\n') on the private key string from the environment.
affects: *
breakingRequires Node.js >=20.8.1; older versions (e.g., Node 18) will throw runtime errors.
fix
Upgrade Node.js to v20.8.1 or later.
affects: >=1.0.0
deprecatedThe add() method returns the created document directly (not a DocumentReference) in v1.6.0.
fix
Document data is returned from add(); no need to call .get() on a reference.
affects: >=1.0.0
gotchaThe update() method does not support FieldValue.increment() or array operations in this version.
fix
Use set() with merge option or implement manual read-modify-write.
affects: <=1.6.0
gotchaQueries using collection(...).where() return a QuerySnapshot; you must call .get() to execute.
fix
Always chain .get() after building query constraints.
affects: *
Errors
Common errors & fixes
Error: Invalid private key format
Private key string from environment variable lacks proper newline characters.
fix
Replace escaped newlines with actual newlines: privateKey: process.env.PRIVATE_KEY?.replace(/\\n/g, '\n')
TypeError: createFirestoreClient is not a function
Using CommonJS require() on an ESM-only package.
fix
Change to ESM import: import { createFirestoreClient } from 'firebase-rest-firestore'
Error: Failed to fetch access token
Incorrect projectId, clientEmail, or privateKey configuration.
fix
Verify Firebase service account credentials and that the private key is correctly formatted.
Upgrade
Version history
1.6.0latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
9 hits · last 30 days
node
8
Resources
firebase-rest-firestore — npm install firebase-rest-firestore · libregistry