BETTER-AUTH. UI
Mutations

useChangePassword

Change the authenticated user's password.

The server uses revokeOtherSessions to decide whether it revokes existing sessions. This hook does not update the cache.

Usage

import { authClient } from "@/lib/auth-client"
import { useChangePassword } from "@better-auth-ui/react"

const { mutate: changePassword } = useChangePassword(authClient)

changePassword({
  currentPassword: "hunter2",
  newPassword: "hunter3",
  revokeOtherSessions: true
})

Options factory

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

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

Params

Prop

Type

Last updated on

On this page