Mutations
useGenerateBackupCodes
Replace the existing backup codes.
The new codes are returned once. Keep them in component state and let the user copy them — they are never returned again.
Usage
import {
type TwoFactorAuthClient,
useAuth,
useGenerateBackupCodes
} from "@better-auth-ui/react"
const { authClient } = useAuth()
const { mutate: generateBackupCodes } = useGenerateBackupCodes(
authClient as TwoFactorAuthClient
)
generateBackupCodes({ password: "current-password" })useGenerateBackupCodes requires the Better Auth twoFactor plugin. Cast authClient to TwoFactorAuthClient so TypeScript picks up the plugin-extended method signature.
Options factory
import { generateBackupCodesOptions } from "@better-auth-ui/react"
import { useMutation } from "@tanstack/react-query"
const { mutate } = useMutation(generateBackupCodesOptions(authClient))Params
Prop
Type
Last updated on