File tree Expand file tree Collapse file tree 2 files changed +26
-1
lines changed Expand file tree Collapse file tree 2 files changed +26
-1
lines changed Original file line number Diff line number Diff line change @@ -134,3 +134,24 @@ export function extractRefs(
134134
135135 return dataAndRefs
136136}
137+
138+ /**
139+ * Custom stringifier for [devalue](https://github.com/Rich-Harris/devalue) to support Firestore Timestamp and GeoPoint
140+ * on SSR.
141+ */
142+ export const devalueCustomStringifiers = {
143+ TimeStamp : ( data : unknown ) => data instanceof Timestamp && data . toJSON ( ) ,
144+ GeoPoint : ( data : unknown ) => data instanceof GeoPoint && data . toJSON ( ) ,
145+ }
146+
147+ /**
148+ * Custom parsers for [devalue](https://github.com/Rich-Harris/devalue) to support Firestore Timestamp and GeoPoint on
149+ * SSR.
150+ */
151+ export const devalueCustomParsers = {
152+ TimeStamp : ( data : ReturnType < Timestamp [ 'toJSON' ] > ) =>
153+ new Timestamp ( data . seconds , data . nanoseconds ) ,
154+
155+ GeoPoint : ( data : ReturnType < GeoPoint [ 'toJSON' ] > ) =>
156+ new GeoPoint ( data . latitude , data . longitude ) ,
157+ }
Original file line number Diff line number Diff line change @@ -31,7 +31,11 @@ export type {
3131 */
3232export { useCollection , useDocument , useFirestore } from './firestore'
3333export { firestoreOptionsDefaults as globalFirestoreOptions } from './firestore/bind'
34- export { firestoreDefaultConverter } from './firestore/utils'
34+ export {
35+ firestoreDefaultConverter ,
36+ devalueCustomParsers ,
37+ devalueCustomStringifiers ,
38+ } from './firestore/utils'
3539export type {
3640 UseCollectionOptions ,
3741 UseDocumentOptions ,
You can’t perform that action at this time.
0 commit comments