Skip to content

React - Functions

Non-hook fetch functions for use outside of components. Useful when you want to fetch data with libraries like React Query.

Usage with React Query

ts
import { getDocument } from "@typed-firestore/react";

const { data, isError } = useQuery({
  queryKey: [collectionRef.path, documentId],
  queryFn: () => getDocument(collectionRef, documentId),
});

API Reference

FunctionDescription
getDocumentFetch a document
getDocumentDataFetch only the data part of a document
getDocumentMaybeFetch a document that might not exist
getDocumentDataMaybeFetch only the data part of a document that might not exist
getDocumentTxFetch a document as part of a transaction
getDocumentMaybeTxFetch a document that might not exist as part of a transaction
getSpecificDocumentFetch a specific document
getSpecificDocumentDataFetch only the data part of a specific document
getSpecificDocumentTxFetch a specific document as part of a transaction

Released under the Apache-2.0 License.