---
title: "useReauthentication"
description: "useReauthentication, auto-imported in the app: its options, return value and types."
canonical_url: "https://nuxt-backend.dev/docs/reference/api/use-reauthentication"
---
# useReauthentication

Version: nuxt-backend 0.6.x · Tab: Reference · Kind: reference · Status: stable

Every page: [llms.txt](https://nuxt-backend.dev/llms.txt) · Skill for coding agents: [nuxt-backend](https://nuxt-backend.dev/.well-known/skills/nuxt-backend/SKILL.md)

Commands use npm; use your project's package manager.

## Interfaces

### UseReauthenticationOptions

Defined in: [src/runtime/vue/composables/use-reauthentication.ts](https://github.com/qruto/nuxt-backend/blob/main/src/runtime/vue/composables/use-reauthentication.ts)

#### Properties

<table>
<thead>
  <tr>
    <th>
      Property
    </th>
    
    <th>
      Type
    </th>
    
    <th>
      Description
    </th>
    
    <th>
      Defined in
    </th>
  </tr>
</thead>

<tbody>
  <tr>
    <td>
      <a id="prompt">
        
      </a>
      
       <code>
        prompt?
      </code>
    </td>
    
    <td>
      <code>
        boolean
      </code>
    </td>
    
    <td>
      This component asks the person itself, with markup of its own over <code>
        isRequired
      </code>
      
      , <code>
        step
      </code>
      
       and the step actions. While it is mounted, <code>
        reauthenticate()
      </code>
      
       waits for it, and a <code>
        <ReauthenticateDialog>
      </code>
      
       mounted after it stays closed. With no prompt on the page, neither one of these nor a <code>
        <ReauthenticateDialog>
      </code>
      
      , nobody can confirm: what asks is refused at once, as it came, and a development build warns.
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/runtime/vue/composables/use-reauthentication.ts" rel="nofollow">
        src/runtime/vue/composables/use-reauthentication.ts
      </a>
    </td>
  </tr>
</tbody>
</table>

---

### UseReauthenticationReturn

Defined in: [src/runtime/vue/composables/use-reauthentication.ts](https://github.com/qruto/nuxt-backend/blob/main/src/runtime/vue/composables/use-reauthentication.ts)

#### Properties

<table>
<thead>
  <tr>
    <th>
      Property
    </th>
    
    <th>
      Type
    </th>
    
    <th>
      Description
    </th>
    
    <th>
      Defined in
    </th>
  </tr>
</thead>

<tbody>
  <tr>
    <td>
      <a id="isrequired">
        
      </a>
      
       <code>
        isRequired
      </code>
    </td>
    
    <td>
      <code>
        ComputedRef
      </code>
      
      <<code>
        boolean
      </code>
      
      >
    </td>
    
    <td>
      <code>
        true
      </code>
      
       while the app waits for the person to sign in again: an action was refused as <code>
        reauthentication_required
      </code>
      
      , or <code>
        reauthenticate()
      </code>
      
       asked. <code>
        <ReauthenticateDialog>
      </code>
      
       is open while it is. App-wide: every call of the composable reads the same one.
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/runtime/vue/composables/use-reauthentication.ts" rel="nofollow">
        src/runtime/vue/composables/use-reauthentication.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="step">
        
      </a>
      
       <code>
        step
      </code>
    </td>
    
    <td>
      <code>
        Ref
      </code>
      
      <<a href="#reauthenticationstep">
        <code>
          ReauthenticationStep
        </code>
      </a>
      
      >
    </td>
    
    <td>
      Where the person is: <code>
        choose
      </code>
      
       (a passkey, or a code), then <code>
        verify-code
      </code>
      
      .
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/runtime/vue/composables/use-reauthentication.ts" rel="nofollow">
        src/runtime/vue/composables/use-reauthentication.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="email">
        
      </a>
      
       <code>
        email
      </code>
    </td>
    
    <td>
      <code>
        ComputedRef
      </code>
      
      <<code>
        string
      </code>
      
       | <code>
        null
      </code>
      
      >
    </td>
    
    <td>
      The address the code goes to: the signed-in account's own, never one typed in.
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/runtime/vue/composables/use-reauthentication.ts" rel="nofollow">
        src/runtime/vue/composables/use-reauthentication.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="otp">
        
      </a>
      
       <code>
        otp
      </code>
    </td>
    
    <td>
      <code>
        Ref
      </code>
      
      <<code>
        string
      </code>
      
      >
    </td>
    
    <td>
      The code the person typed, for <code>
        verifyCode
      </code>
      
      .
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/runtime/vue/composables/use-reauthentication.ts" rel="nofollow">
        src/runtime/vue/composables/use-reauthentication.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="ispending">
        
      </a>
      
       <code>
        isPending
      </code>
    </td>
    
    <td>
      <code>
        ComputedRef
      </code>
      
      <<code>
        boolean
      </code>
      
      >
    </td>
    
    <td>
      <code>
        true
      </code>
      
       while a step's call runs.
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/runtime/vue/composables/use-reauthentication.ts" rel="nofollow">
        src/runtime/vue/composables/use-reauthentication.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="error">
        
      </a>
      
       <code>
        error
      </code>
    </td>
    
    <td>
      <code>
        Ref
      </code>
      
      < | <a href="https://nuxt-backend.dev/docs/reference/api/functions#backenderror">
        <code>
          BackendError
        </code>
      </a>
      
       | <code>
        null
      </code>
      
      >
    </td>
    
    <td>
      Why the last step failed, or <code>
        null
      </code>
      
      : a closed passkey prompt (<code>
        invalid_input
      </code>
      
       on <code>
        passkey
      </code>
      
      ), a wrong code, another account's passkey (<code>
        forbidden
      </code>
      
      , reason <code>
        other_account
      </code>
      
      ), a rate limit.
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/runtime/vue/composables/use-reauthentication.ts" rel="nofollow">
        src/runtime/vue/composables/use-reauthentication.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="retryafter">
        
      </a>
      
       <code>
        retryAfter
      </code>
    </td>
    
    <td>
      <code>
        Ref
      </code>
      
      <<code>
        number
      </code>
      
       | <code>
        null
      </code>
      
      >
    </td>
    
    <td>
      Seconds until a rate-limited step can be retried; <code>
        null
      </code>
      
       otherwise.
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/runtime/vue/composables/use-reauthentication.ts" rel="nofollow">
        src/runtime/vue/composables/use-reauthentication.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="withpasskey">
        
      </a>
      
       <code>
        withPasskey
      </code>
    </td>
    
    <td>
      () => <code>
        Promise
      </code>
      
      <<code>
        void
      </code>
      
      >
    </td>
    
    <td>
      Sign in again with a passkey on this device. Never rejects: a failure stays in <code>
        error
      </code>
      
      .
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/runtime/vue/composables/use-reauthentication.ts" rel="nofollow">
        src/runtime/vue/composables/use-reauthentication.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="sendcode">
        
      </a>
      
       <code>
        sendCode
      </code>
    </td>
    
    <td>
      () => <code>
        Promise
      </code>
      
      <<code>
        void
      </code>
      
      >
    </td>
    
    <td>
      Email a code to the account's own address → <code>
        verify-code
      </code>
      
      . Never rejects.
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/runtime/vue/composables/use-reauthentication.ts" rel="nofollow">
        src/runtime/vue/composables/use-reauthentication.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="verifycode">
        
      </a>
      
       <code>
        verifyCode
      </code>
    </td>
    
    <td>
      () => <code>
        Promise
      </code>
      
      <<code>
        void
      </code>
      
      >
    </td>
    
    <td>
      Sign in again with the code. Never rejects.
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/runtime/vue/composables/use-reauthentication.ts" rel="nofollow">
        src/runtime/vue/composables/use-reauthentication.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="back">
        
      </a>
      
       <code>
        back
      </code>
    </td>
    
    <td>
      () => <code>
        void
      </code>
    </td>
    
    <td>
      Back to <code>
        choose
      </code>
      
      , the code cleared.
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/runtime/vue/composables/use-reauthentication.ts" rel="nofollow">
        src/runtime/vue/composables/use-reauthentication.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="cancel">
        
      </a>
      
       <code>
        cancel
      </code>
    </td>
    
    <td>
      () => <code>
        void
      </code>
    </td>
    
    <td>
      Stop waiting: what waits rejects with the <code>
        reauthentication_required
      </code>
      
       refusal, and the session stays as it was.
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/runtime/vue/composables/use-reauthentication.ts" rel="nofollow">
        src/runtime/vue/composables/use-reauthentication.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="reauthenticate">
        
      </a>
      
       <code>
        reauthenticate
      </code>
    </td>
    
    <td>
      () => <code>
        Promise
      </code>
      
      <<code>
        void
      </code>
      
      >
    </td>
    
    <td>
      Ask the person to sign in again now. Resolves once they did, with a fresh session and the token that names it; rejects with the <code>
        reauthentication_required
      </code>
      
       refusal when they cancel, and at once when no prompt is mounted to ask them (<code>
        <ReauthenticateDialog>
      </code>
      
      , or a component of your own with <code>
        prompt: true
      </code>
      
      ). One request at a time: a second call waits on the same sign-in.
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/runtime/vue/composables/use-reauthentication.ts" rel="nofollow">
        src/runtime/vue/composables/use-reauthentication.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="withreauthentication">
        
      </a>
      
       <code>
        withReauthentication
      </code>
    </td>
    
    <td>
      <<code>
        T
      </code>
      
      >(<code>
        action
      </code>
      
      ) => <code>
        Promise
      </code>
      
      <<code>
        T
      </code>
      
      >
    </td>
    
    <td>
      Run <code>
        action
      </code>
      
      . When the server refuses it as <code>
        reauthentication_required
      </code>
      
       (a sensitive action, and a sign-in older than it takes), ask the person to sign in again, then run it once more and settle with that. A cancelled sign-in rejects with the first refusal; any other failure rejects as it came.
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/runtime/vue/composables/use-reauthentication.ts" rel="nofollow">
        src/runtime/vue/composables/use-reauthentication.ts
      </a>
    </td>
  </tr>
</tbody>
</table>

## Type Aliases

### ReauthenticationStep

```ts
type ReauthenticationStep = "choose" | "verify-code";
```

Defined in: [src/runtime/vue/composables/use-reauthentication.ts](https://github.com/qruto/nuxt-backend/blob/main/src/runtime/vue/composables/use-reauthentication.ts)

Where a re-authentication is: choosing a passkey or a code, then entering the code.

## Functions

### useReauthentication()

```ts
function useReauthentication(options?): UseReauthenticationReturn;
```

Defined in: [src/runtime/vue/composables/use-reauthentication.ts](https://github.com/qruto/nuxt-backend/blob/main/src/runtime/vue/composables/use-reauthentication.ts)

Asking the person to confirm it is them before a sensitive action: the
client half of `requireRecentSignIn` and of the routes that take a recent
sign-in. A sensitive action refused as `reauthentication_required` goes
through `withReauthentication`, which opens `<ReauthenticateDialog>`
(mounted by the packaged pages and settings components, or once by your
layout), waits for the person to sign in again — passkey first, or a
code to the account's own address — and runs the action once more.

Signing in again opens a new session for the same account: the server
refuses another account's passkey (`forbidden`, reason `other_account`),
keeps the active workspace, and signs the old session out. The flow then
refreshes the session and waits for the live connection to take up the
new token, so the retried action carries the new sign-in; while it still
carries the old one, the action is tried again a moment later, a few times.

The state is the app's: every call reads the same `isRequired`, `step`
and `error`, so one dialog serves every action, and a component that
builds its own dialog wires these to its markup and says `prompt: true`.
With no prompt mounted, nobody can confirm: `withReauthentication`
rejects with the refusal as it came. The step actions never reject;
`reauthenticate` and `withReauthentication` resolve or reject.

#### Parameters

<table>
<thead>
  <tr>
    <th>
      Parameter
    </th>
    
    <th>
      Type
    </th>
  </tr>
</thead>

<tbody>
  <tr>
    <td>
      <code>
        options?
      </code>
    </td>
    
    <td>
      <a href="#usereauthenticationoptions">
        <code>
          UseReauthenticationOptions
        </code>
      </a>
    </td>
  </tr>
</tbody>
</table>

#### Returns

[`UseReauthenticationReturn`](#usereauthenticationreturn)

#### Example

```vue
<script setup lang="ts">
const { withReauthentication } = useReauthentication()
const { remove } = usePasskeys()

// Asks the person to confirm it is them when their sign-in is too old.
const removePasskey = (id: string) => withReauthentication(() => remove(id))
</script>
<template>
  <ReauthenticateDialog />
</template>
```


## Sitemap

See the full [sitemap](https://nuxt-backend.dev/sitemap.md) for all pages.
