The Firebase JS SDK is now in BETA!
This EAP site is no longer maintained. See the official Firebase Documentation site for the latest documentation and information about the Firebase JS SDK.

Home > @firebase/firestore > / > CollectionReference > withConverter

CollectionReference.withConverter() method

Applies a custom data converter to this CollectionReference, allowing you to use your own custom model objects with Firestore. When you call addDoc() with the returned CollectionReference instance, the provided converter will convert between Firestore data and your custom type U.

Signature:

withConverter<U>(converter: FirestoreDataConverter<U>): CollectionReference<U>;

Parameters

Parameter Type Description
converter FirestoreDataConverter<U> Converts objects to and from Firestore.

Returns:

CollectionReference<U>

A CollectionReference<U> that uses the provided converter.