Skip to content

Latest commit

 

History

History

reference

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 

ReactFire reference docs

ReactFire reference docs

Table of contents

Classes

Interfaces

Type Aliases

Variables

Functions

Type Aliases

ObservableStatus

Ƭ ObservableStatus<T>: ObservableStatusLoading<T> | ObservableStatusError<T> | ObservableStatusSuccess<T>

Type parameters

Name
T

Defined in

src/useObservable.ts:84


ReactFireGlobals

Ƭ ReactFireGlobals: Object

Type declaration

Name Type
_reactFireDatabaseCachedQueries DatabaseQuery[]
_reactFireFirestoreQueryCache FirestoreQuery[]
_reactFirePreloadedObservables Map<string, SuspenseSubject<any>>

Defined in

src/index.ts:6


SigninCheckResult

Ƭ SigninCheckResult: { errors: {} ; hasRequiredClaims: false ; signedIn: false ; user: null } | { errors: ClaimCheckErrors ; hasRequiredClaims: boolean ; signedIn: true ; user: User }

Defined in

src/auth.tsx:59


StorageImageProps

Ƭ StorageImageProps: Object

Type declaration

Name Type
placeHolder? JSX.Element
storage? FirebaseStorage
storagePath string
suspense? boolean

Defined in

src/storage.tsx:36

Variables

AnalyticsSdkContext

Const AnalyticsSdkContext: Context<undefined | Analytics>

Defined in

src/sdk.tsx:20


AppCheckSdkContext

Const AppCheckSdkContext: Context<undefined | AppCheck>

Defined in

src/sdk.tsx:18


AuthSdkContext

Const AuthSdkContext: Context<undefined | Auth>

Defined in

src/sdk.tsx:19


DatabaseSdkContext

Const DatabaseSdkContext: Context<undefined | Database>

Defined in

src/sdk.tsx:21


FirestoreSdkContext

Const FirestoreSdkContext: Context<undefined | Firestore>

Defined in

src/sdk.tsx:22


FunctionsSdkContext

Const FunctionsSdkContext: Context<undefined | Functions>

Defined in

src/sdk.tsx:23


PerformanceSdkContext

Const PerformanceSdkContext: Context<undefined | FirebasePerformance>

Defined in

src/sdk.tsx:25


RemoteConfigSdkContext

Const RemoteConfigSdkContext: Context<undefined | RemoteConfig>

Defined in

src/sdk.tsx:26


StorageSdkContext

Const StorageSdkContext: Context<undefined | FirebaseStorage>

Defined in

src/sdk.tsx:24


version

Const version: string

Defined in

src/firebaseApp.tsx:20

Functions

AnalyticsProvider

AnalyticsProvider(props): Element

Parameters

Name Type
props PropsWithChildren<{ sdk: Analytics }>

Returns

Element

Defined in

src/sdk.tsx:31


AppCheckProvider

AppCheckProvider(props): Element

Parameters

Name Type
props PropsWithChildren<{ sdk: AppCheck }>

Returns

Element

Defined in

src/sdk.tsx:31


AuthCheck

AuthCheck(«destructured»): JSX.Element

Deprecated

Use useSigninCheck instead

Conditionally render children based on signed-in status and custom claims.

Meant for Concurrent mode only (<FirebaseAppProvider suspense=true />). More detail.

Parameters

Name Type
«destructured» AuthCheckProps

Returns

JSX.Element

Defined in

src/auth.tsx:247


AuthProvider

AuthProvider(props): Element

Parameters

Name Type
props PropsWithChildren<{ sdk: Auth }>

Returns

Element

Defined in

src/sdk.tsx:31


ClaimsCheck

ClaimsCheck(«destructured»): Element

Deprecated

Use useSigninCheck instead

Conditionally render children based on custom claims.

Meant for Concurrent mode only (<FirebaseAppProvider suspense=true />). More detail.

Parameters

Name Type
«destructured» ClaimsCheckProps

Returns

Element

Defined in

src/auth.tsx:203


DatabaseProvider

DatabaseProvider(props): Element

Parameters

Name Type
props PropsWithChildren<{ sdk: Database }>

Returns

Element

Defined in

src/sdk.tsx:31


FirebaseAppProvider

FirebaseAppProvider(props): Element

Parameters

Name Type
props PropsWithChildren<FirebaseAppProviderProps>

Returns

Element

Defined in

src/firebaseApp.tsx:24


FirestoreProvider

FirestoreProvider(props): Element

Parameters

Name Type
props PropsWithChildren<{ sdk: Firestore }>

Returns

Element

Defined in

src/sdk.tsx:31


FunctionsProvider

FunctionsProvider(props): Element

Parameters

Name Type
props PropsWithChildren<{ sdk: Functions }>

Returns

Element

Defined in

src/sdk.tsx:31


PerformanceProvider

PerformanceProvider(props): Element

Parameters

Name Type
props PropsWithChildren<{ sdk: FirebasePerformance }>

Returns

Element

Defined in

src/sdk.tsx:31


RemoteConfigProvider

RemoteConfigProvider(props): Element

Parameters

Name Type
props PropsWithChildren<{ sdk: RemoteConfig }>

Returns

Element

Defined in

src/sdk.tsx:31


StorageImage

StorageImage(props): Element

Parameters

Name Type
props StorageImageProps & ClassAttributes<HTMLImageElement> & ImgHTMLAttributes<HTMLImageElement>

Returns

Element

Defined in

src/storage.tsx:78


StorageProvider

StorageProvider(props): Element

Parameters

Name Type
props PropsWithChildren<{ sdk: FirebaseStorage }>

Returns

Element

Defined in

src/sdk.tsx:31


SuspenseWithPerf

SuspenseWithPerf(«destructured»): JSX.Element

Parameters

Name Type
«destructured» SuspensePerfProps

Returns

JSX.Element

Defined in

src/performance.tsx:9


checkIdField

checkIdField(options): any

Parameters

Name Type
options ReactFireOptions<unknown>

Returns

any

Defined in

src/index.ts:47


checkOptions

checkOptions(options, field): any

Parameters

Name Type
options ReactFireOptions<unknown>
field string

Returns

any

Defined in

src/index.ts:34


checkinitialData

checkinitialData(options): any

Parameters

Name Type
options ReactFireOptions<unknown>

Returns

any

Defined in

src/index.ts:43


preloadFirestoreDoc

preloadFirestoreDoc(refProvider): Promise<SuspenseSubject<DocumentSnapshot<DocumentData>>>

Preload a subscription to a Firestore document reference.

Use this to warm up useFirestoreDoc for a specific document

Parameters

Name Type
refProvider () => Promise<DocumentReference<DocumentData>>

Returns

Promise<SuspenseSubject<DocumentSnapshot<DocumentData>>>

Defined in

src/firestore.tsx:28


preloadObservable

preloadObservable<T>(source, id, suspenseEnabled?): SuspenseSubject<T>

Type parameters

Name
T

Parameters

Name Type Default value
source Observable<T> undefined
id string undefined
suspenseEnabled boolean false

Returns

SuspenseSubject<T>

Defined in

src/useObservable.ts:20


preloadUser

preloadUser(authResolver): Promise<undefined | null | User>

Parameters

Name Type
authResolver () => Promise<Auth>

Returns

Promise<undefined | null | User>

Defined in

src/auth.tsx:11


useAnalytics

useAnalytics(): Analytics

Returns

Analytics

Defined in

src/sdk.tsx:84


useAppCheck

useAppCheck(): AppCheck

Returns

AppCheck

Defined in

src/sdk.tsx:82


useAuth

useAuth(): Auth

Returns

Auth

Defined in

src/sdk.tsx:83


useCallableFunctionResponse

useCallableFunctionResponse<RequestData, ResponseData>(functionName, options?): ObservableStatus<ResponseData>

Calls a callable function.

Type parameters

Name
RequestData
ResponseData

Parameters

Name Type Description
functionName string The name of the function to call
options? ReactFireOptions<ResponseData> & { data?: RequestData ; httpsCallableOptions?: HttpsCallableOptions }

Returns

ObservableStatus<ResponseData>

Defined in

src/functions.tsx:13


useDatabase

useDatabase(): Database

Returns

Database

Defined in

src/sdk.tsx:85


useDatabaseList

useDatabaseList<T>(ref, options?): ObservableStatus<QueryChange[] | T[]>

Subscribe to a Realtime Database list

Type parameters

Name Type
T { [key: string]: unknown; }

Parameters

Name Type Description
ref Query | DatabaseReference Reference to the DB List you want to listen to
options? ReactFireOptions<T[]>

Returns

ObservableStatus<QueryChange[] | T[]>

Defined in

src/database.tsx:48


useDatabaseListData

useDatabaseListData<T>(ref, options?): ObservableStatus<T[] | null>

Type parameters

Name Type
T { [key: string]: unknown; }

Parameters

Name Type
ref Query | DatabaseReference
options? ReactFireOptions<T[]>

Returns

ObservableStatus<T[] | null>

Defined in

src/database.tsx:58


useDatabaseObject

useDatabaseObject<T>(ref, options?): ObservableStatus<QueryChange | T>

Subscribe to a Realtime Database object

Type parameters

Name Type
T unknown

Parameters

Name Type Description
ref DatabaseReference Reference to the DB object you want to listen to
options? ReactFireOptions<T>

Returns

ObservableStatus<QueryChange | T>

Defined in

src/database.tsx:27


useDatabaseObjectData

useDatabaseObjectData<T>(ref, options?): ObservableStatus<T>

Type parameters

Name
T

Parameters

Name Type
ref DatabaseReference
options? ReactFireOptions<T>

Returns

ObservableStatus<T>

Defined in

src/database.tsx:34


useFirebaseApp

useFirebaseApp(): FirebaseApp

Returns

FirebaseApp

Defined in

src/firebaseApp.tsx:78


useFirestore

useFirestore(): Firestore

Returns

Firestore

Defined in

src/sdk.tsx:86


useFirestoreCollection

useFirestoreCollection<T>(query, options?): ObservableStatus<QuerySnapshot<T>>

Subscribe to a Firestore collection

Type parameters

Name Type
T DocumentData

Parameters

Name Type
query Query<T>
options? ReactFireOptions<T[]>

Returns

ObservableStatus<QuerySnapshot<T>>

Defined in

src/firestore.tsx:86


useFirestoreCollectionData

useFirestoreCollectionData<T>(query, options?): ObservableStatus<T[]>

Subscribe to a Firestore collection and unwrap the snapshot into an array.

Type parameters

Name Type
T DocumentData

Parameters

Name Type
query Query<T>
options? ReactFireOptions<T[]>

Returns

ObservableStatus<T[]>

Defined in

src/firestore.tsx:96


useFirestoreDoc

useFirestoreDoc<T>(ref, options?): ObservableStatus<DocumentSnapshot<T>>

Subscribe to Firestore Document changes

You can preload data for this hook by calling preloadFirestoreDoc

Type parameters

Name Type
T DocumentData

Parameters

Name Type
ref DocumentReference<T>
options? ReactFireOptions<T>

Returns

ObservableStatus<DocumentSnapshot<T>>

Defined in

src/firestore.tsx:42


useFirestoreDocData

useFirestoreDocData<T>(ref, options?): ObservableStatus<T>

Subscribe to Firestore Document changes and unwrap the document into a plain object

Type parameters

Name Type
T unknown

Parameters

Name Type
ref DocumentReference<T>
options? ReactFireOptions<T>

Returns

ObservableStatus<T>

Defined in

src/firestore.tsx:62


useFirestoreDocDataOnce

useFirestoreDocDataOnce<T>(ref, options?): ObservableStatus<T>

Get a Firestore document, unwrap the document into a plain object, and don't subscribe to changes

Type parameters

Name Type
T unknown

Parameters

Name Type
ref DocumentReference<T>
options? ReactFireOptions<T>

Returns

ObservableStatus<T>

Defined in

src/firestore.tsx:74


useFirestoreDocOnce

useFirestoreDocOnce<T>(ref, options?): ObservableStatus<DocumentSnapshot<T>>

Get a firestore document and don't subscribe to changes

Type parameters

Name Type
T DocumentData

Parameters

Name Type
ref DocumentReference<T>
options? ReactFireOptions<T>

Returns

ObservableStatus<DocumentSnapshot<T>>

Defined in

src/firestore.tsx:52


useFunctions

useFunctions(): Functions

Returns

Functions

Defined in

src/sdk.tsx:87


useIdTokenResult

useIdTokenResult(user, forceRefresh?, options?): ObservableStatus<IdTokenResult>

Parameters

Name Type Default value
user User undefined
forceRefresh boolean false
options? ReactFireOptions<IdTokenResult> undefined

Returns

ObservableStatus<IdTokenResult>

Defined in

src/auth.tsx:31


useInitAnalytics

useInitAnalytics(initializer, options?): ObservableStatus<Analytics>

Parameters

Name Type
initializer (firebaseApp: FirebaseApp) => Promise<Analytics>
options? ReactFireOptions<Analytics>

Returns

ObservableStatus<Analytics>

Defined in

src/sdk.tsx:92


useInitAppCheck

useInitAppCheck(initializer, options?): ObservableStatus<AppCheck>

Parameters

Name Type
initializer (firebaseApp: FirebaseApp) => Promise<AppCheck>
options? ReactFireOptions<AppCheck>

Returns

ObservableStatus<AppCheck>

Defined in

src/sdk.tsx:92


useInitAuth

useInitAuth(initializer, options?): ObservableStatus<Auth>

Parameters

Name Type
initializer (firebaseApp: FirebaseApp) => Promise<Auth>
options? ReactFireOptions<Auth>

Returns

ObservableStatus<Auth>

Defined in

src/sdk.tsx:92


useInitDatabase

useInitDatabase(initializer, options?): ObservableStatus<Database>

Parameters

Name Type
initializer (firebaseApp: FirebaseApp) => Promise<Database>
options? ReactFireOptions<Database>

Returns

ObservableStatus<Database>

Defined in

src/sdk.tsx:92


useInitFirestore

useInitFirestore(initializer, options?): ObservableStatus<Firestore>

Parameters

Name Type
initializer (firebaseApp: FirebaseApp) => Promise<Firestore>
options? ReactFireOptions<Firestore>

Returns

ObservableStatus<Firestore>

Defined in

src/sdk.tsx:92


useInitFunctions

useInitFunctions(initializer, options?): ObservableStatus<Functions>

Parameters

Name Type
initializer (firebaseApp: FirebaseApp) => Promise<Functions>
options? ReactFireOptions<Functions>

Returns

ObservableStatus<Functions>

Defined in

src/sdk.tsx:92


useInitPerformance

useInitPerformance(initializer, options?): ObservableStatus<FirebasePerformance>

Parameters

Name Type
initializer (firebaseApp: FirebaseApp) => Promise<FirebasePerformance>
options? ReactFireOptions<FirebasePerformance>

Returns

ObservableStatus<FirebasePerformance>

Defined in

src/sdk.tsx:92


useInitRemoteConfig

useInitRemoteConfig(initializer, options?): ObservableStatus<RemoteConfig>

Parameters

Name Type
initializer (firebaseApp: FirebaseApp) => Promise<RemoteConfig>
options? ReactFireOptions<RemoteConfig>

Returns

ObservableStatus<RemoteConfig>

Defined in

src/sdk.tsx:92


useInitStorage

useInitStorage(initializer, options?): ObservableStatus<FirebaseStorage>

Parameters

Name Type
initializer (firebaseApp: FirebaseApp) => Promise<FirebaseStorage>
options? ReactFireOptions<FirebaseStorage>

Returns

ObservableStatus<FirebaseStorage>

Defined in

src/sdk.tsx:92


useIsSuspenseEnabled

useIsSuspenseEnabled(): boolean

Returns

boolean

Defined in

src/firebaseApp.tsx:60


useObservable

useObservable<T>(observableId, source, config?): ObservableStatus<T>

Type parameters

Name Type
T unknown

Parameters

Name Type
observableId string
source Observable<T>
config ReactFireOptions<unknown>

Returns

ObservableStatus<T>

Defined in

src/useObservable.ts:86


usePerformance

usePerformance(): FirebasePerformance

Returns

FirebasePerformance

Defined in

src/sdk.tsx:88


useRemoteConfig

useRemoteConfig(): RemoteConfig

Returns

RemoteConfig

Defined in

src/sdk.tsx:90


useRemoteConfigAll

useRemoteConfigAll(key): ObservableStatus<AllParameters>

Convience method similar to useRemoteConfigValue. Returns allRemote Config parameters.

Parameters

Name Type Description
key string The parameter key in Remote Config

Returns

ObservableStatus<AllParameters>

Defined in

src/remote-config.tsx:66


useRemoteConfigBoolean

useRemoteConfigBoolean(key): ObservableStatus<boolean>

Convience method similar to useRemoteConfigValue. Returns a boolean from a Remote Config parameter.

Parameters

Name Type Description
key string The parameter key in Remote Config

Returns

ObservableStatus<boolean>

Defined in

src/remote-config.tsx:58


useRemoteConfigNumber

useRemoteConfigNumber(key): ObservableStatus<number>

Convience method similar to useRemoteConfigValue. Returns a number from a Remote Config parameter.

Parameters

Name Type Description
key string The parameter key in Remote Config

Returns

ObservableStatus<number>

Defined in

src/remote-config.tsx:50


useRemoteConfigString

useRemoteConfigString(key): ObservableStatus<string>

Convience method similar to useRemoteConfigValue. Returns a string from a Remote Config parameter.

Parameters

Name Type Description
key string The parameter key in Remote Config

Returns

ObservableStatus<string>

Defined in

src/remote-config.tsx:42


useRemoteConfigValue

useRemoteConfigValue(key): ObservableStatus<RemoteConfigValue>

Accepts a key and optionally a Remote Config instance. Returns a Remote Config Value.

Parameters

Name Type Description
key string The parameter key in Remote Config

Returns

ObservableStatus<RemoteConfigValue>

Defined in

src/remote-config.tsx:34


useSigninCheck

useSigninCheck(options?): ObservableStatus<SigninCheckResult>

Subscribe to the signed-in status of a user.

const { status, data:signInCheckResult } = useSigninCheck();

if (status === 'loading') {
  return <LoadingSpinner />}

if (signInCheckResult.signedIn === true) {
  return <ProfilePage user={signInCheckResult.user}/>
} else {
  return <SignInForm />
}

Optionally check custom claims of a user as well.

// pass in an object describing the custom claims a user must have
const {status, data: signInCheckResult} = useSigninCheck({requiredClaims: {admin: true}});

// pass in a custom claims validator function
const {status, data: signInCheckResult} = useSigninCheck({validateCustomClaims: (userClaims) => {
  // custom validation logic...
}});

// You can optionally force-refresh the token
const {status, data: signInCheckResult} = useSigninCheck({forceRefresh: true, requiredClaims: {admin: true}});

Parameters

Name Type
options? SignInCheckOptionsBasic | SignInCheckOptionsClaimsObject | SignInCheckOptionsClaimsValidator

Returns

ObservableStatus<SigninCheckResult>

Defined in

src/auth.tsx:124


useStorage

useStorage(): FirebaseStorage

Returns

FirebaseStorage

Defined in

src/sdk.tsx:89


useStorageDownloadURL

useStorageDownloadURL<T>(ref, options?): ObservableStatus<string | T>

Subscribe to a storage ref's download URL

Type parameters

Name Type
T string

Parameters

Name Type Description
ref StorageReference reference to the blob you want to download
options? ReactFireOptions<T>

Returns

ObservableStatus<string | T>

Defined in

src/storage.tsx:29


useStorageTask

useStorageTask<T>(task, ref, options?): ObservableStatus<UploadTaskSnapshot | T>

Subscribe to the progress of a storage task

Type parameters

Name Type
T unknown

Parameters

Name Type Description
task UploadTask the task you want to listen to
ref StorageReference reference to the blob the task is acting on
options? ReactFireOptions<T>

Returns

ObservableStatus<UploadTaskSnapshot | T>

Defined in

src/storage.tsx:16


useSuspenseEnabledFromConfigAndContext

useSuspenseEnabledFromConfigAndContext(suspenseFromConfig?): boolean

Parameters

Name Type
suspenseFromConfig? boolean

Returns

boolean

Defined in

src/firebaseApp.tsx:67


useUser

useUser<T>(options?): ObservableStatus<User | null>

Subscribe to Firebase auth state changes, including token refresh

Type parameters

Name Type
T unknown

Parameters

Name Type
options? ReactFireOptions<T>

Returns

ObservableStatus<User | null>

Defined in

src/auth.tsx:22