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

getDoc() function

Reads the document referred to by the specified document reference.

All documents are directly fetched from the server, even if the document was previously read or modified. Recent modifications are only reflected in the retrieved DocumentSnapshot if they have already been applied by the backend. If the client is offline, the read fails. If you like to use caching or see local modifications, please use the full Firestore SDK.

Signature:

export declare function getDoc<T>(reference: DocumentReference<T>): Promise<DocumentSnapshot<T>>;

Parameters

Parameter Type Description
reference DocumentReference<T> The reference of the document to fetch.

Returns:

Promise<DocumentSnapshot<T>>

A Promise resolved with a DocumentSnapshot containing the current document contents.