Registry / database / firestore-timestamp-formatter

firestore-timestamp-formatter

JSON →
library1.0.4jsnpmunverified

Firestore Timestamp Formatter (v1.0.4) converts Firestore Timestamp objects to JavaScript Date objects automatically using Firestore's withConverter method. It eliminates the need for manual toDate() calls on each document field. The package is simple, focusing solely on timestamp conversion, and is compatible with any Firestore client library. It operates exclusively in the browser or Node.js environments that support Firestore.

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 exports a default converter object. Use ESM import as shown.

import TimestampConverter from 'firestore-timestamp-formatter';

The default export is the object itself; there is no named export. Using curly braces will result in undefined.

import TimestampConverter from 'firestore-timestamp-formatter';

The package does not ship TypeScript definitions. You may need to declare a module or use @types if available.

import TimestampConverter from 'firestore-timestamp-formatter';

Fetch a Firestore document with automatic timestamp-to-Date conversion using withConverter.

import { initializeApp } from 'firebase/app'; import { getFirestore, doc, getDoc } from 'firebase/firestore'; import TimestampConverter from 'firestore-timestamp-formatter'; const firebaseConfig = { /* your config */ }; const app = initializeApp(firebaseConfig); const db = getFirestore(app); const docRef = doc(db, 'users', 'user123'); const docSnap = await getDoc(docRef.withConverter(TimestampConverter)); if (docSnap.exists()) { const data = docSnap.data(); console.log(data.createdAt); // Date object } else { console.log('No such document!'); }
Debug
Known footguns
gotchaOnly top-level Timestamp fields are converted; nested objects or arrays containing Timestamps are not converted.
gotchaThe converter only handles Firestore Timestamp objects; it does not convert other Firestore types like GeoPoint or Reference.
deprecatedPackage has not been updated in over 2 years; no compatibility guarantee with newer Firestore versions.
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
19 hits · last 30 days
bingbot
11
gptbot
3
ahrefsbot
2
mj12bot
1
Resources