BETTER-AUTH. UI
Mutations

useSendVerificationOtp

Email a one-time code for any email-OTP flow.

One endpoint backs every email-OTP flow. type picks which one: "sign-in", "email-verification", "forget-password", or "change-email".

Usage

import {
  type EmailOtpAuthClient,
  useAuth,
  useSendVerificationOtp
} from "@better-auth-ui/react"

const { authClient } = useAuth()
const { mutate: sendVerificationOtp } = useSendVerificationOtp(
  authClient as EmailOtpAuthClient
)

sendVerificationOtp({
  email: "[email protected]",
  type: "sign-in"
})

useSendVerificationOtp requires the Better Auth emailOTP plugin. Cast authClient to EmailOtpAuthClient so TypeScript picks up the plugin-extended method signature.

Options factory

import { sendVerificationOtpOptions } from "@better-auth-ui/react"
import { useMutation } from "@tanstack/react-query"

const { mutate } = useMutation(sendVerificationOtpOptions(authClient))

Params

Prop

Type

Last updated on

On this page