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 > lite > DocumentReference > withConverter

DocumentReference.withConverter() method

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

Signature:

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

Parameters

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

Returns:

DocumentReference<U>

A DocumentReference<U> that uses the provided converter.