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

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

### AccountApi

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

The export functions re-exported from your `backend/account.ts`.

#### Properties

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

<tbody>
  <tr>
    <td>
      <a id="exportaccountdata">
        
      </a>
      
       <code>
        exportAccountData?
      </code>
    </td>
    
    <td>
      <a href="https://docs.convex.dev/api/modules/server#functionreference" rel="nofollow">
        <code>
          FunctionReference
        </code>
      </a>
      
      <<code>
        "action"
      </code>
      
      , <code>
        "public"
      </code>
      
      , <code>
        Record
      </code>
      
      <<code>
        string
      </code>
      
      , <code>
        never
      </code>
      
      >, <a href="https://nuxt-backend.dev/docs/reference/api/account#accountexport">
        <code>
          AccountExport
        </code>
      </a>
      
      >
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/runtime/vue/composables/use-account.ts" rel="nofollow">
        src/runtime/vue/composables/use-account.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="getaccountexport">
        
      </a>
      
       <code>
        getAccountExport?
      </code>
    </td>
    
    <td>
      <a href="https://docs.convex.dev/api/modules/server#functionreference" rel="nofollow">
        <code>
          FunctionReference
        </code>
      </a>
      
      <<code>
        "query"
      </code>
      
      , <code>
        "public"
      </code>
      
      , <code>
        Record
      </code>
      
      <<code>
        string
      </code>
      
      , <code>
        never
      </code>
      
      >, | <a href="https://nuxt-backend.dev/docs/reference/api/account#accountexportstatus">
        <code>
          AccountExportStatus
        </code>
      </a>
      
       | <code>
        null
      </code>
      
      >
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/runtime/vue/composables/use-account.ts" rel="nofollow">
        src/runtime/vue/composables/use-account.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="getaccountdeletion">
        
      </a>
      
       <code>
        getAccountDeletion?
      </code>
    </td>
    
    <td>
      <a href="https://docs.convex.dev/api/modules/server#functionreference" rel="nofollow">
        <code>
          FunctionReference
        </code>
      </a>
      
      <<code>
        "query"
      </code>
      
      , <code>
        "public"
      </code>
      
      , <code>
        Record
      </code>
      
      <<code>
        string
      </code>
      
      , <code>
        never
      </code>
      
      >, | <a href="https://nuxt-backend.dev/docs/reference/api/account#accountdeletion">
        <code>
          AccountDeletion
        </code>
      </a>
      
       | <code>
        null
      </code>
      
      >
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/runtime/vue/composables/use-account.ts" rel="nofollow">
        src/runtime/vue/composables/use-account.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="cancelaccountdeletion">
        
      </a>
      
       <code>
        cancelAccountDeletion?
      </code>
    </td>
    
    <td>
      <a href="https://docs.convex.dev/api/modules/server#functionreference" rel="nofollow">
        <code>
          FunctionReference
        </code>
      </a>
      
      <<code>
        "mutation"
      </code>
      
      , <code>
        "public"
      </code>
      
      , { <code>
        token?
      </code>
      
      : <code>
        string
      </code>
      
      ; }, <code>
        boolean
      </code>
      
      >
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/runtime/vue/composables/use-account.ts" rel="nofollow">
        src/runtime/vue/composables/use-account.ts
      </a>
    </td>
  </tr>
</tbody>
</table>

---

### UseAccountOptions

Defined in: [src/runtime/vue/composables/use-account.ts](https://github.com/qruto/nuxt-backend/blob/main/src/runtime/vue/composables/use-account.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="api">
        
      </a>
      
       <code>
        api?
      </code>
    </td>
    
    <td>
      <a href="#accountapi">
        <code>
          AccountApi
        </code>
      </a>
    </td>
    
    <td>
      Override the injected <code>
        api.account
      </code>
      
       namespace.
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/runtime/vue/composables/use-account.ts" rel="nofollow">
        src/runtime/vue/composables/use-account.ts
      </a>
    </td>
  </tr>
</tbody>
</table>

---

### ProfileFields

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

The profile fields `updateProfile` saves.

#### Properties

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

<tbody>
  <tr>
    <td>
      <a id="name">
        
      </a>
      
       <code>
        name?
      </code>
    </td>
    
    <td>
      <code>
        string
      </code>
    </td>
    
    <td>
      The display name.
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/runtime/vue/composables/use-account.ts" rel="nofollow">
        src/runtime/vue/composables/use-account.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="image">
        
      </a>
      
       <code>
        image?
      </code>
    </td>
    
    <td>
      <code>
        string
      </code>
      
       | <code>
        null
      </code>
    </td>
    
    <td>
      The avatar image URL, or <code>
        null
      </code>
      
       to remove it.
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/runtime/vue/composables/use-account.ts" rel="nofollow">
        src/runtime/vue/composables/use-account.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="locale">
        
      </a>
      
       <code>
        locale?
      </code>
    </td>
    
    <td>
      <code>
        string
      </code>
    </td>
    
    <td>
      The language every email the package sends the account is written in: a language tag such as <code>
        de
      </code>
      
       or <code>
        pt-BR
      </code>
      
      .
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/runtime/vue/composables/use-account.ts" rel="nofollow">
        src/runtime/vue/composables/use-account.ts
      </a>
    </td>
  </tr>
</tbody>
</table>

---

### UseAccountReturn

Defined in: [src/runtime/vue/composables/use-account.ts](https://github.com/qruto/nuxt-backend/blob/main/src/runtime/vue/composables/use-account.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="latestexport">
        
      </a>
      
       <code>
        latestExport
      </code>
    </td>
    
    <td>
      <code>
        ComputedRef
      </code>
      
      < | <a href="https://nuxt-backend.dev/docs/reference/api/account#accountexport">
        <code>
          AccountExport
        </code>
      </a>
      
       | <code>
        null
      </code>
      
       | <code>
        undefined
      </code>
      
      >
    </td>
    
    <td>
      The newest export whose link still works, live: it turns <code>
        null
      </code>
      
       when the link expires. <code>
        null
      </code>
      
       when there is none and when signed out; <code>
        undefined
      </code>
      
       while the session or the export is still being read.
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/runtime/vue/composables/use-account.ts" rel="nofollow">
        src/runtime/vue/composables/use-account.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="exportsleft">
        
      </a>
      
       <code>
        exportsLeft
      </code>
    </td>
    
    <td>
      <code>
        ComputedRef
      </code>
      
      <<code>
        number
      </code>
      
       | <code>
        undefined
      </code>
      
      >
    </td>
    
    <td>
      How many more exports the account may make today (three a day); <code>
        0
      </code>
      
       when signed out, <code>
        undefined
      </code>
      
       while it is read.
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/runtime/vue/composables/use-account.ts" rel="nofollow">
        src/runtime/vue/composables/use-account.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="confirmation">
        
      </a>
      
       <code>
        confirmation
      </code>
    </td>
    
    <td>
      <code>
        ComputedRef
      </code>
      
      <<code>
        string
      </code>
      
      >
    </td>
    
    <td>
      What the person types to confirm a deletion: the account's own address, as <code>
        deleteAccount
      </code>
      
       checks it. <code>
        ''
      </code>
      
       when signed out.
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/runtime/vue/composables/use-account.ts" rel="nofollow">
        src/runtime/vue/composables/use-account.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="isloading">
        
      </a>
      
       <code>
        isLoading
      </code>
    </td>
    
    <td>
      <code>
        ComputedRef
      </code>
      
      <<code>
        boolean
      </code>
      
      >
    </td>
    
    <td>
      <code>
        true
      </code>
      
       while the session or the export is still being read.
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/runtime/vue/composables/use-account.ts" rel="nofollow">
        src/runtime/vue/composables/use-account.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="deletion">
        
      </a>
      
       <code>
        deletion
      </code>
    </td>
    
    <td>
      <code>
        ComputedRef
      </code>
      
      < | <a href="https://nuxt-backend.dev/docs/reference/api/account#accountdeletion">
        <code>
          AccountDeletion
        </code>
      </a>
      
       | <code>
        null
      </code>
      
       | <code>
        undefined
      </code>
      
      >
    </td>
    
    <td>
      The deletion waiting out its grace period, live: <code>
        { requestedAt, deletesAt }
      </code>
      
       (epoch ms), or <code>
        null
      </code>
      
       when none is scheduled and when signed out; <code>
        undefined
      </code>
      
       while it is read. The account works as before until <code>
        deletesAt
      </code>
      
      ; <code>
        cancelDeletion()
      </code>
      
       keeps it.
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/runtime/vue/composables/use-account.ts" rel="nofollow">
        src/runtime/vue/composables/use-account.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 <code>
        updateProfile
      </code>
      
      , <code>
        exportData
      </code>
      
      , <code>
        deleteAccount
      </code>
      
       or <code>
        cancelDeletion
      </code>
      
       runs.
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/runtime/vue/composables/use-account.ts" rel="nofollow">
        src/runtime/vue/composables/use-account.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="error">
        
      </a>
      
       <code>
        error
      </code>
    </td>
    
    <td>
      <code>
        ComputedRef
      </code>
      
      < | <a href="https://nuxt-backend.dev/docs/reference/api/functions#backenderror">
        <code>
          BackendError
        </code>
      </a>
      
       | <code>
        null
      </code>
      
      >
    </td>
    
    <td>
      Why the last action failed, else why the export could not be read, else <code>
        null
      </code>
      
      . Reads never reject.
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/runtime/vue/composables/use-account.ts" rel="nofollow">
        src/runtime/vue/composables/use-account.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="updateprofile">
        
      </a>
      
       <code>
        updateProfile
      </code>
    </td>
    
    <td>
      (<code>
        fields
      </code>
      
      ) => <code>
        Promise
      </code>
      
      <<code>
        void
      </code>
      
      >
    </td>
    
    <td>
      Save the account's profile: its name, its avatar and its language. Never the email address (<code>
        useEmailChange
      </code>
      
       moves the account, with a code from each address); a language tag that is not one is refused. Rejects on failure.
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/runtime/vue/composables/use-account.ts" rel="nofollow">
        src/runtime/vue/composables/use-account.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="exportdata">
        
      </a>
      
       <code>
        exportData
      </code>
    </td>
    
    <td>
      () => <code>
        Promise
      </code>
      
      <<a href="https://nuxt-backend.dev/docs/reference/api/account#accountexport">
        <code>
          AccountExport
        </code>
      </a>
      
      >
    </td>
    
    <td>
      Export everything the app keeps of the account into one JSON file, behind a link that expires within the hour; resolves with it. At most three a day (<code>
        rate_limited
      </code>
      
      , limit <code>
        accountExport
      </code>
      
      ), and never for an administrator acting as the account (<code>
        forbidden
      </code>
      
      , reason <code>
        impersonating
      </code>
      
      ). Rejects on failure.
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/runtime/vue/composables/use-account.ts" rel="nofollow">
        src/runtime/vue/composables/use-account.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="deleteaccount">
        
      </a>
      
       <code>
        deleteAccount
      </code>
    </td>
    
    <td>
      (<code>
        confirmation
      </code>
      
      ) => <code>
        Promise
      </code>
      
      <<code>
        void
      </code>
      
      >
    </td>
    
    <td>
      Schedule the account's deletion: <code>
        confirmation
      </code>
      
       is the address the person typed. The account works as before for the grace period, an email tells the person the date and carries a link that keeps the account, and <code>
        deletion
      </code>
      
       holds the date. Then the account is erased everywhere. It takes a recent sign-in (wrap it in <code>
        useReauthentication().withReauthentication
      </code>
      
      ), and is refused to the only owner of a workspace others belong to (<code>
        forbidden
      </code>
      
      , reason <code>
        sole_owner
      </code>
      
      ). Rejects on failure.
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/runtime/vue/composables/use-account.ts" rel="nofollow">
        src/runtime/vue/composables/use-account.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="canceldeletion">
        
      </a>
      
       <code>
        cancelDeletion
      </code>
    </td>
    
    <td>
      () => <code>
        Promise
      </code>
      
      <<code>
        boolean
      </code>
      
      >
    </td>
    
    <td>
      Keep the account: cancel its scheduled deletion. A second email confirms. Resolves with whether a deletion was cancelled. Rejects on failure.
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/runtime/vue/composables/use-account.ts" rel="nofollow">
        src/runtime/vue/composables/use-account.ts
      </a>
    </td>
  </tr>
</tbody>
</table>

## Functions

### useAccount()

```ts
function useAccount(options?): UseAccountReturn;
```

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

The account itself: its profile, its export and its deletion. Save the
name, the avatar and the language with `updateProfile`; download
everything the app keeps of the account, and delete it for good. The
export runs `exportAccountData` from `backend/account.ts`, and the newest
export's link is a live query over `getAccountExport`, so it disappears
the moment it expires. The deletion is scheduled, once the person typed
their address (`confirmation`) and signed in recently: `deletion` holds
when it happens, `cancelDeletion()` keeps the account, and when the grace
period ends an erasure removes the account's data everywhere, the billing
and email providers included.

#### Parameters

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

<tbody>
  <tr>
    <td>
      <code>
        options?
      </code>
    </td>
    
    <td>
      <a href="#useaccountoptions">
        <code>
          UseAccountOptions
        </code>
      </a>
    </td>
  </tr>
</tbody>
</table>

#### Returns

[`UseAccountReturn`](#useaccountreturn)

#### Example

```vue
<script setup lang="ts">
const account = useAccount()
const { withReauthentication } = useReauthentication()
const typed = ref('')
</script>
<template>
  <a v-if="account.latestExport.value" :href="account.latestExport.value.url">Download</a>
  <button :aria-disabled="account.isPending.value || undefined" @click="account.exportData()">Export my data</button>
  <p v-if="account.deletion.value">Deleted on {{ new Date(account.deletion.value.deletesAt).toLocaleDateString() }}</p>
  <button v-if="account.deletion.value" @click="account.cancelDeletion()">Keep my account</button>
  <input v-model="typed" :placeholder="account.confirmation.value">
  <button @click="withReauthentication(() => account.deleteAccount(typed))">Delete my account</button>
</template>
```

## References

### AccountDeletion

Re-exports [AccountDeletion](https://nuxt-backend.dev/docs/reference/api/account#accountdeletion)

---

### AccountExport

Re-exports [AccountExport](https://nuxt-backend.dev/docs/reference/api/account#accountexport)

---

### AccountExportStatus

Re-exports [AccountExportStatus](https://nuxt-backend.dev/docs/reference/api/account#accountexportstatus)


## Sitemap

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