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

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

### FlagOverride

Defined in: [src/convex/flags.ts](https://github.com/qruto/nuxt-backend/blob/main/src/convex/flags.ts)

What an administrator stores for a flag. Every field is optional: an
override with none holds the flag at its default.

#### Properties

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

<tbody>
  <tr>
    <td>
      <a id="enabled">
        
      </a>
      
       <code>
        enabled?
      </code>
    </td>
    
    <td>
      <code>
        boolean
      </code>
    </td>
    
    <td>
      On or off for everyone, over the code's default. Targets and the rollout apply only while it is off.
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/flags.ts" rel="nofollow">
        src/convex/flags.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="users">
        
      </a>
      
       <code>
        users?
      </code>
    </td>
    
    <td>
      <code>
        string
      </code>
      
      <span>
        
      </span>
    </td>
    
    <td>
      Account ids it is on for.
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/flags.ts" rel="nofollow">
        src/convex/flags.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="workspaces">
        
      </a>
      
       <code>
        workspaces?
      </code>
    </td>
    
    <td>
      <code>
        string
      </code>
      
      <span>
        
      </span>
    </td>
    
    <td>
      Workspace ids it is on for.
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/flags.ts" rel="nofollow">
        src/convex/flags.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="plans">
        
      </a>
      
       <code>
        plans?
      </code>
    </td>
    
    <td>
      <code>
        string
      </code>
      
      <span>
        
      </span>
    </td>
    
    <td>
      Plan keys of the catalog it is on for: a billing entity on one of them sees it.
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/flags.ts" rel="nofollow">
        src/convex/flags.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="rollout">
        
      </a>
      
       <code>
        rollout?
      </code>
    </td>
    
    <td>
      <code>
        number
      </code>
    </td>
    
    <td>
      The percentage of accounts (or workspaces) it is on for, 0 to 100, picked by a stable hash.
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/flags.ts" rel="nofollow">
        src/convex/flags.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="message">
        
      </a>
      
       <code>
        message?
      </code>
    </td>
    
    <td>
      <code>
        string
      </code>
    </td>
    
    <td>
      The maintenance banner's message: the <code>
        maintenance
      </code>
      
       switch only.
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/flags.ts" rel="nofollow">
        src/convex/flags.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="winner">
        
      </a>
      
       <code>
        winner?
      </code>
    </td>
    
    <td>
      <code>
        string
      </code>
    </td>
    
    <td>
      An experiment's winner: everyone sees this variant, and nobody is exposed any more.
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/flags.ts" rel="nofollow">
        src/convex/flags.ts
      </a>
    </td>
  </tr>
</tbody>
</table>

---

### FlagsApiRefs

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

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

#### Properties

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

<tbody>
  <tr>
    <td>
      <a id="getflags">
        
      </a>
      
       <code>
        getFlags?
      </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/flags#flagvalues">
        <code>
          FlagValues
        </code>
      </a>
      
      >
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/runtime/vue/composables/use-flags.ts" rel="nofollow">
        src/runtime/vue/composables/use-flags.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="listflags">
        
      </a>
      
       <code>
        listFlags?
      </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/flags#adminflag">
        <code>
          AdminFlag
        </code>
      </a>
      
      <span>
        
      </span>
      
       | <code>
        null
      </code>
      
      >
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/runtime/vue/composables/use-flags.ts" rel="nofollow">
        src/runtime/vue/composables/use-flags.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="setflag">
        
      </a>
      
       <code>
        setFlag?
      </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>
        key
      </code>
      
      : <code>
        string
      </code>
      
      ; <code>
        override
      </code>
      
      : <a href="#flagoverride">
        <code>
          FlagOverride
        </code>
      </a>
      
       | <code>
        null
      </code>
      
      ; }, <code>
        null
      </code>
      
      >
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/runtime/vue/composables/use-flags.ts" rel="nofollow">
        src/runtime/vue/composables/use-flags.ts
      </a>
    </td>
  </tr>
</tbody>
</table>

---

### UseFlagOptions

Defined in: [src/runtime/vue/composables/use-flags.ts](https://github.com/qruto/nuxt-backend/blob/main/src/runtime/vue/composables/use-flags.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="server">
        
      </a>
      
       <code>
        server?
      </code>
    </td>
    
    <td>
      <code>
        boolean
      </code>
    </td>
    
    <td>
      Read the flags on the server too (default <code>
        true
      </code>
      
      ), so the page's HTML is rendered with the flag as it is for the visitor. <code>
        false
      </code>
      
       reads in the browser only: the flag reads off until then.
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/runtime/vue/composables/use-flags.ts" rel="nofollow">
        src/runtime/vue/composables/use-flags.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="api">
        
      </a>
      
       <code>
        api?
      </code>
    </td>
    
    <td>
      <a href="#flagsapirefs">
        <code>
          FlagsApiRefs
        </code>
      </a>
    </td>
    
    <td>
      Override the injected <code>
        api.flags
      </code>
      
       namespace.
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/runtime/vue/composables/use-flags.ts" rel="nofollow">
        src/runtime/vue/composables/use-flags.ts
      </a>
    </td>
  </tr>
</tbody>
</table>

---

### UseFlagReturn

Defined in: [src/runtime/vue/composables/use-flags.ts](https://github.com/qruto/nuxt-backend/blob/main/src/runtime/vue/composables/use-flags.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="isenabled">
        
      </a>
      
       <code>
        isEnabled
      </code>
    </td>
    
    <td>
      <code>
        ComputedRef
      </code>
      
      <<code>
        boolean
      </code>
      
      >
    </td>
    
    <td>
      Whether the flag is on for the signed-in person (or the visitor), live. <code>
        false
      </code>
      
       until it is read, and for a flag the app does not declare.
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/runtime/vue/composables/use-flags.ts" rel="nofollow">
        src/runtime/vue/composables/use-flags.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>
      
       until the flags are first read.
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/runtime/vue/composables/use-flags.ts" rel="nofollow">
        src/runtime/vue/composables/use-flags.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 flags could not be read, else <code>
        null
      </code>
      
      . The read never throws.
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/runtime/vue/composables/use-flags.ts" rel="nofollow">
        src/runtime/vue/composables/use-flags.ts
      </a>
    </td>
  </tr>
</tbody>
</table>

---

### UseFlagAdminOptions

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

---

### UseFlagAdminReturn

Defined in: [src/runtime/vue/composables/use-flags.ts](https://github.com/qruto/nuxt-backend/blob/main/src/runtime/vue/composables/use-flags.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="flags">
        
      </a>
      
       <code>
        flags
      </code>
    </td>
    
    <td>
      <code>
        ComputedRef
      </code>
      
      < | <a href="https://nuxt-backend.dev/docs/reference/api/flags#adminflag">
        <code>
          AdminFlag
        </code>
      </a>
      
      <span>
        
      </span>
      
       | <code>
        undefined
      </code>
      
      >
    </td>
    
    <td>
      Every flag with its default and override, the package's own first, live: <code>
        []
      </code>
      
       for a caller who is no administrator, <code>
        undefined
      </code>
      
       while it is read.
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/runtime/vue/composables/use-flags.ts" rel="nofollow">
        src/runtime/vue/composables/use-flags.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="isloading-1">
        
      </a>
      
       <code>
        isLoading
      </code>
    </td>
    
    <td>
      <code>
        ComputedRef
      </code>
      
      <<code>
        boolean
      </code>
      
      >
    </td>
    
    <td>
      <code>
        true
      </code>
      
       while the list is first read.
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/runtime/vue/composables/use-flags.ts" rel="nofollow">
        src/runtime/vue/composables/use-flags.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="isrefused">
        
      </a>
      
       <code>
        isRefused
      </code>
    </td>
    
    <td>
      <code>
        ComputedRef
      </code>
      
      <<code>
        boolean
      </code>
      
      >
    </td>
    
    <td>
      <code>
        true
      </code>
      
       once the list answered that this caller is no administrator.
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/runtime/vue/composables/use-flags.ts" rel="nofollow">
        src/runtime/vue/composables/use-flags.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 change is saved.
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/runtime/vue/composables/use-flags.ts" rel="nofollow">
        src/runtime/vue/composables/use-flags.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="error-1">
        
      </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 change failed, else why the list 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-flags.ts" rel="nofollow">
        src/runtime/vue/composables/use-flags.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="setflag-1">
        
      </a>
      
       <code>
        setFlag
      </code>
    </td>
    
    <td>
      (<code>
        key
      </code>
      
      , <code>
        override
      </code>
      
      ) => <code>
        Promise
      </code>
      
      <<code>
        void
      </code>
      
      >
    </td>
    
    <td>
      Store a flag's override: on or off for everyone, its targets and its rollout; <code>
        null
      </code>
      
       removes it, so the flag holds its default. Takes a recent sign-in (<code>
        useReauthentication().withReauthentication
      </code>
      
       asks for one). Rejects on failure.
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/runtime/vue/composables/use-flags.ts" rel="nofollow">
        src/runtime/vue/composables/use-flags.ts
      </a>
    </td>
  </tr>
</tbody>
</table>

## Functions

### useFlag()

```ts
function useFlag(key, options?): UseFlagReturn;
```

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

Whether a feature flag is on for whoever is looking: their account,
their active workspace and their plan, as `backend/flags.ts` declares
the flag and the admin console overrides it. One of the package's own
reads too: `useFlag('pause_checkout')` is on while checkout is paused.

Rendered on the server: the flags ride in the page's payload, so the
HTML already shows the flag as it is, and the read then stays live. Every
`useFlag` on a page shares one read. The flag is a hint for the page:
the server decides with `flags.requireFlag`.

#### Parameters

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

<tbody>
  <tr>
    <td>
      <code>
        key
      </code>
    </td>
    
    <td>
      <code>
        MaybeRefOrGetter
      </code>
      
      <<code>
        string
      </code>
      
      >
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        options?
      </code>
    </td>
    
    <td>
      <a href="#useflagoptions">
        <code>
          UseFlagOptions
        </code>
      </a>
    </td>
  </tr>
</tbody>
</table>

#### Returns

[`UseFlagReturn`](#useflagreturn)

#### Example

```vue
<script setup lang="ts">
const { isEnabled } = useFlag('newEditor')
</script>
<template>
  <NewEditor v-if="isEnabled" />
  <ClassicEditor v-else />
</template>
```

---

### useFlagAdmin()

```ts
function useFlagAdmin(options?): UseFlagAdminReturn;
```

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

The admin console's Flags tab, as data: every flag with its default and
its override, and the change an administrator makes, through
`listFlags` and `setFlag` of `backend/flags.ts`. Every change is an
administrator's in person, takes a recent sign-in, and is recorded on the
activity trail. A caller who is no administrator reads an empty list and
`isRefused`.

#### Parameters

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

<tbody>
  <tr>
    <td>
      <code>
        options?
      </code>
    </td>
    
    <td>
      <a href="#useflagadminoptions">
        <code>
          UseFlagAdminOptions
        </code>
      </a>
    </td>
  </tr>
</tbody>
</table>

#### Returns

[`UseFlagAdminReturn`](#useflagadminreturn)

#### Example

```vue
<script setup lang="ts">
const { flags, setFlag } = useFlagAdmin()
const { withReauthentication } = useReauthentication()
const pauseCheckout = (on: boolean) => withReauthentication(() => setFlag('pause_checkout', { enabled: on }))
</script>
```

## References

### AdminFlag

Re-exports [AdminFlag](https://nuxt-backend.dev/docs/reference/api/flags#adminflag)

---

### FlagValues

Re-exports [FlagValues](https://nuxt-backend.dev/docs/reference/api/flags#flagvalues)


## Sitemap

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