BETTER-AUTH. UI
Mutations

useResetPasswordOtp

Reset a password with an emailed code.

There is no token in the URL — the code and the new password are submitted in one call.

Usage

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

const { authClient } = useAuth()
const { mutate: resetPasswordOtp } = useResetPasswordOtp(
  authClient as EmailOtpAuthClient
)

resetPasswordOtp({
  email: "[email protected]",
  otp: "123456",
  password: "new-password"
})

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

Options factory

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

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

Params

Prop

Type

Last updated on

On this page