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

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

Usage

1import { useAuthenticate } from "@account-kit/react";
2
3const { authenticate, authenticateAsync, isPending, error } = useAuthenticate({
4 // these are optional
5 onSuccess: () => {
6 // do something on success
7 },
8 onError: (error) => console.error(error),
9});

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