Skip to content
Alchemy Logo

useAuthenticate

function useAuthenticate(mutationArgs?): UseAuthenticateResult;

Defined in: account-kit/react/src/hooks/useAuthenticate.ts:50

Hook that provides functions and state for authenticating a user using a signer. It includes methods for both synchronous and asynchronous mutations. Useful if building your own UI components and want to control the authentication flow. For authenticate vs authenticateAsync, use authenticate when you want the hook the handle state changes for you, authenticateAsync when you need to wait for the result to finish processing.

This can be complex for magic link or OTP flows: OPT calls authenticate twice, but this should be handled by the signer.

import { useAuthenticate } from "@account-kit/react";
 
const { authenticate, authenticateAsync, isPending, error } = useAuthenticate({
  // these are optional
  onSuccess: () => {
    // do something on success
  },
  onError: (error) => console.error(error),
});

ParameterTypeDescription

mutationArgs?

Partial<Omit<UseMutationOptions<User, Error, AuthParams, unknown>, "mutationFn" | "mutationKey">>

Optional mutation arguments to configure the authentication mutation. ref

UseAuthenticateResult

An object containing functions and state for handling user authentication, including methods for synchronously and asynchronously executing the authentication. ref

Was this page helpful?