{"id":47683,"library":"firebase-rest-firestore","title":"Firebase REST Firestore","description":"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.","status":"active","version":"1.6.0","language":"javascript","source_language":"en","source_url":"https://github.com/nabettu/firebase-rest-firestore","tags":["javascript","firebase","firestore","rest","api","edge","cloudflare","workers","vercel","typescript"],"install":[{"cmd":"npm install firebase-rest-firestore","lang":"bash","label":"npm"},{"cmd":"yarn add firebase-rest-firestore","lang":"bash","label":"yarn"},{"cmd":"pnpm add firebase-rest-firestore","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"The package is ESM-only; CommonJS require is not supported.","wrong":"const createFirestoreClient = require('firebase-rest-firestore')","symbol":"createFirestoreClient","correct":"import { createFirestoreClient } from 'firebase-rest-firestore'"},{"note":"The FirestoreClient class is exported as a named export. It is primarily used for type annotations.","wrong":"","symbol":"FirestoreClient","correct":"import { FirestoreClient } from 'firebase-rest-firestore'"},{"note":"FieldValue is a named export providing sentinels like serverTimestamp().","wrong":"","symbol":"FieldValue","correct":"import { FieldValue } from 'firebase-rest-firestore'"},{"note":"The package does not have a default export; use namespace import if needed.","wrong":"import FirebaseRestFirestore from 'firebase-rest-firestore'","symbol":"default import","correct":"import * as FirebaseRestFirestore from 'firebase-rest-firestore'"}],"quickstart":{"code":"import { createFirestoreClient, FieldValue } from 'firebase-rest-firestore';\n\nconst firestore = createFirestoreClient({\n  projectId: process.env.FIREBASE_PROJECT_ID ?? '',\n  privateKey: (process.env.FIREBASE_PRIVATE_KEY ?? '').replace(/\\\\n/g, '\\n'),\n  clientEmail: process.env.FIREBASE_CLIENT_EMAIL ?? '',\n});\n\nasync function main() {\n  const doc = await firestore.add('users', {\n    name: 'Alice',\n    createdAt: FieldValue.serverTimestamp(),\n  });\n  console.log('Created document:', doc.id);\n\n  const retrieved = await firestore.get('users', doc.id);\n  console.log('Retrieved:', retrieved);\n\n  const results = await firestore\n    .collection('users')\n    .where('name', '==', 'Alice')\n    .get();\n  console.log('Query count:', results.size);\n}\n\nmain().catch(console.error);","lang":"typescript","description":"Shows creating a client, adding a document with server timestamp, retrieving by ID, and querying with a filter."},"warnings":[{"fix":"Use .replace(/\\\\n/g, '\\n') on the private key string from the environment.","message":"Private key must have literal newlines replaced with actual newlines; environment variables often strip newlines.","severity":"gotcha","affected_versions":"*"},{"fix":"Upgrade Node.js to v20.8.1 or later.","message":"Requires Node.js >=20.8.1; older versions (e.g., Node 18) will throw runtime errors.","severity":"breaking","affected_versions":">=1.0.0"},{"fix":"Document data is returned from add(); no need to call .get() on a reference.","message":"The add() method returns the created document directly (not a DocumentReference) in v1.6.0.","severity":"deprecated","affected_versions":">=1.0.0"},{"fix":"Use set() with merge option or implement manual read-modify-write.","message":"The update() method does not support FieldValue.increment() or array operations in this version.","severity":"gotcha","affected_versions":"<=1.6.0"},{"fix":"Always chain .get() after building query constraints.","message":"Queries using collection(...).where() return a QuerySnapshot; you must call .get() to execute.","severity":"gotcha","affected_versions":"*"}],"env_vars":null,"search_vec":"'1.6.0':35 '20.8.1':73 'admin':30 'api':12,47,78 'avoid':55 'cach':43 'cannot':32 'client':13 'cloudflar':21,80 'configur':50 'crud':38 'depend':59 'differenti':52 'edg':16,25,79 'environ':18,57 'explicit':49 'fieldvalu':62 'firebas':1,4,29,75 'firestor':3,6,10,76 'full':37 'function':26 'hidden':56 'intuit':46 'javascript':74 'licens':69 'lightweight':9 'like':64 'mit':68 'node.js':72 'offer':36 'oper':39 'optim':14 'releas':66 'requir':71 'rest':2,5,11,77 'run':33 'runtim':17 'sdk':31 'sentinel':63 'servertimestamp':65 'support':41,61 'token':42 'typescript':40,83 'variabl':58 'vercel':24,82 'version':34 'worker':22,81","created_at":"2026-06-07T16:52:46.410666+00:00","updated_at":"2026-06-07T16:52:46.410666+00:00","problems":[{"fix":"Replace escaped newlines with actual newlines: privateKey: process.env.PRIVATE_KEY?.replace(/\\\\n/g, '\\n')","cause":"Private key string from environment variable lacks proper newline characters.","error":"Error: Invalid private key format"},{"fix":"Change to ESM import: import { createFirestoreClient } from 'firebase-rest-firestore'","cause":"Using CommonJS require() on an ESM-only package.","error":"TypeError: createFirestoreClient is not a function"},{"fix":"Verify Firebase service account credentials and that the private key is correctly formatted.","cause":"Incorrect projectId, clientEmail, or privateKey configuration.","error":"Error: Failed to fetch access token"}],"ecosystem":"npm","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null,"cli_name":null,"cli_version":null,"type":"library","homepage":"https://github.com/nabettu/firebase-rest-firestore#readme","github":"https://github.com/nabettu/firebase-rest-firestore","docs":null,"changelog":null,"pypi":null,"npm":"firebase-rest-firestore","openapi_spec":null,"status_page":null,"smithery":null,"categories":["database"],"base_url":null,"auth_type":null,"provenance":{"verified_status":null,"verified_at":null,"last_verified":"2026-06-07","next_check":"2026-09-05","install_tag":null}}