diff --git a/functions/README.md b/functions/README.md index 5008942..40040a5 100644 --- a/functions/README.md +++ b/functions/README.md @@ -27,6 +27,9 @@ The `useHttpsCallable` hook takes the following parameters: - `functions`: `functions.Functions` instance for your Firebase app - `name`: A `string` representing the name of the function to call +- `options`: (optional) `Object` with the following parameters: + - `timeout`: (optional) `number` Time in milliseconds after which to cancel if there is no response + - `limitedUseAppCheckTokens`: (optional) `boolean` If set to true, uses limited-use App Check token for callable function requests from this instance of `Functions` Returns: diff --git a/functions/useHttpsCallable.ts b/functions/useHttpsCallable.ts index 28b14f6..fe9e49b 100644 --- a/functions/useHttpsCallable.ts +++ b/functions/useHttpsCallable.ts @@ -1,6 +1,7 @@ import { Functions, httpsCallable, + HttpsCallableOptions, HttpsCallableResult, } from 'firebase/functions'; import { useCallback, useState } from 'react'; @@ -20,7 +21,8 @@ export type HttpsCallableHook< export default ( functions: Functions, - name: string + name: string, + options?: HttpsCallableOptions, ): HttpsCallableHook => { const [error, setError] = useState(); const [loading, setLoading] = useState(false); @@ -31,7 +33,8 @@ export default ( ): Promise | undefined> => { const callable = httpsCallable( functions, - name + name, + options, ); setLoading(true); setError(undefined); @@ -43,7 +46,7 @@ export default ( setLoading(false); } }, - [functions, name] + [functions, name, options] ); return [callCallable, loading, error] as const;