useAuth

useAuth

A custom React hook that manages user authentication and authorization.

Usage



function MyComponent(props) {
  const { signIn, signOut, loading, user } = useAuth()

  // use the signIn, signOut, loading, and user values to render the component
}

Arguments

This hook takes no arguments.

Returns

  • user (User | null): An object representing the authenticated user, or null if no user is authenticated.

  • loading (boolean): A boolean indicating whether the hook is currently in the process of fetching data.

  • signIn (({ hmac, email }: { hmac: any; email: any }) => Promise<void>): A function that accepts an object with two properties, hmac and email, and returns a promise that resolves when the user is signed in.

  • signOut (() => Promise<void>): A function that returns a promise that resolves when the user is signed out.

Last updated