Skip to content
Alchemy Logo

useSendVerificationCode

function useSendVerificationCode(mutationArgs?): UseSendVerificationCodeResult;

Defined in: account-kit/react/src/hooks/useSendVerificationCode.ts:74

A custom hook to send OTP verification codes to email or SMS for account verification.

import { useSendVerificationCode } from "@account-kit/react";
 
const { sendVerificationCode, isSendingCode, error } = useSendVerificationCode({
  onSuccess: (data) => {
    console.log("OTP sent");
  },
  onError: (error) => console.error(error),
});
 
// Send verification code to email
sendVerificationCode({
  type: "email",
  contact: "[email protected]",
});
 
// Send verification code to SMS
sendVerificationCodeAsync({
  type: "sms",
  contact: "+1234567890",
});

ParameterTypeDescription

mutationArgs?

Partial<Omit<UseMutationOptions<void, Error, SendVerificationCodeParams, unknown>, "mutationFn" | "mutationKey">>

Optional arguments for the mutation

UseSendVerificationCodeResult

An object containing functions and state for sending verification codes

Was this page helpful?