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 > / > collection

collection() function

Gets a CollectionReference instance that refers to the collection at the specified absolute path.

Signature:

export declare function collection(firestore: FirebaseFirestore, path: string, ...pathSegments: string[]): CollectionReference<DocumentData>;

Parameters

Parameter Type Description
firestore FirebaseFirestore A reference to the root Firestore instance.
path string A slash-separated path to a collection.
pathSegments string[] Additional path segments to apply relative to the first argument.

Returns:

CollectionReference<DocumentData>

The CollectionReference instance.

Exceptions

If the final path has an even number of segments and does not point to a collection.