Skip to content

react-query-firebase / web/auth / useIdToken

Function: useIdToken()

ts
function useIdToken(): object;

Defined in: web/auth/useIdToken.ts:36

A hook to manage the ID token. It monitors changes to the ID token and provides the token itself along with a refresh method to update the token when needed.

Returns

object

idToken

ts
idToken: string;

refresh()

ts
refresh: () => Promise<undefined | string>;

Returns

Promise<undefined | string>

Example

jsx
export const MyComponent = () => {
 const result = useIdToken();
 useEffect(() => {
     const timeout = setTimeout(() => {
         result.refresh();
     }, 5000);
     return () => clearTimeout();
 }, [])
 console.log(resilt.idToken);
};

Released under the MIT License.