Mutations
useVerifyEmailOtp
Verify an email address with a code instead of a link.
Verification signs the user in, so the session query is refetched on success.
Usage
import type { EmailOtpAuthClient } from "@better-auth-ui/core/plugins/email-otp"
import { useAuth } from "@better-auth-ui/react"
import { useVerifyEmailOtp } from "@better-auth-ui/react/plugins/email-otp"
const { authClient } = useAuth()
const { mutate: verifyEmailOtp } = useVerifyEmailOtp(
authClient as EmailOtpAuthClient
)
verifyEmailOtp({
email: "[email protected]",
otp: "123456"
})useVerifyEmailOtp requires the Better Auth emailOTP plugin. Cast authClient to EmailOtpAuthClient so TypeScript picks up the plugin-extended method signature.
Options factory
import { verifyEmailOtpOptions } from "@better-auth-ui/core/plugins/email-otp"
import { useMutation } from "@tanstack/react-query"
const { mutate } = useMutation(verifyEmailOtpOptions(authClient))Params
Prop
Type
Last updated on