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 } from "@better-auth-ui/core/plugins/email-otp"
import { useAuth } from "@better-auth-ui/react"
import { useSendVerificationOtp } from "@better-auth-ui/react/plugins/email-otp"
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/core/plugins/email-otp"
import { useMutation } from "@tanstack/react-query"
const { mutate } = useMutation(sendVerificationOtpOptions(authClient))Params
Prop
Type
Last updated on