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 > setDoc

setDoc() function

Writes to the document referred to by the specified DocumentReference. If the document does not yet exist, it will be created.

The result of this write will only be reflected in document reads that occur after the returned Promise resolves. If the client is offline, the write fails. If you would like to see local modifications or buffer writes until the client is online, use the full Firestore SDK.

Signature:

export declare function setDoc<T>(reference: DocumentReference<T>, data: T): Promise<void>;

Parameters

Parameter Type Description
reference DocumentReference<T> A reference to the document to write.
data T A map of the fields and values for the document.

Returns:

Promise<void>

A Promise resolved once the data has been successfully written to the backend.