Skip to content

useAuthenticate

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

import { useAuthenticate } from "@account-kit/react";

Usage

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),
});

Parameters

mutationArgs

UseAuthenticateMutationArgs Optional mutation arguments to configure the authentication mutation. ref

Returns

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