BETTER-AUTH. UI
Mutations

useGetTotpUri

Re-read the TOTP URI of an enrolled user.

This operation is a mutation because the endpoint uses POST. It accepts the password and returns a secret that the application must not cache.

Usage

import type { TwoFactorAuthClient } from "@better-auth-ui/core/plugins/two-factor"
import { useAuth } from "@better-auth-ui/react"
import { useGetTotpUri } from "@better-auth-ui/react/plugins/two-factor"

const { authClient } = useAuth()
const { mutate: getTotpUri } = useGetTotpUri(
  authClient as TwoFactorAuthClient
)

getTotpUri({ password: "current-password" })

useGetTotpUri requires the Better Auth twoFactor plugin. Cast authClient to TwoFactorAuthClient so TypeScript picks up the plugin-extended method signature.

Options factory

import { getTotpUriOptions } from "@better-auth-ui/core/plugins/two-factor"
import { useMutation } from "@tanstack/react-query"

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

Params

Prop

Type

Last updated on

On this page