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

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

### UseBillingSectionOptions

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

Options for [useBillingSection](#usebillingsection).

#### Properties

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

<tbody>
  <tr>
    <td>
      <a id="labels">
        
      </a>
      
       <code>
        labels?
      </code>
    </td>
    
    <td>
      <code>
        MaybeRefOrGetter
      </code>
      
      < | <a href="https://nuxt-backend.dev/docs/reference/api/use-labels#labeloverrides">
        <code>
          LabelOverrides
        </code>
      </a>
      
      <{ <code>
        title
      </code>
      
      : <code>
        string
      </code>
      
      ; <code>
        emailNotice
      </code>
      
      : <code>
        string
      </code>
      
      ; <code>
        emailOptOut
      </code>
      
      : <code>
        string
      </code>
      
      ; <code>
        description
      </code>
      
      : <code>
        string
      </code>
      
      ; <code>
        period
      </code>
      
      : { <code>
        month
      </code>
      
      : <code>
        string
      </code>
      
      ; <code>
        year
      </code>
      
      : <code>
        string
      </code>
      
      ; }; <code>
        interval
      </code>
      
      : <code>
        string
      </code>
      
      ; <code>
        intervals
      </code>
      
      : { <code>
        month
      </code>
      
      : <code>
        string
      </code>
      
      ; <code>
        year
      </code>
      
      : <code>
        string
      </code>
      
      ; }; <code>
        save
      </code>
      
      : <code>
        string
      </code>
      
      ; <code>
        currency
      </code>
      
      : <code>
        string
      </code>
      
      ; <code>
        loading
      </code>
      
      : <code>
        string
      </code>
      
      ; <code>
        empty
      </code>
      
      : <code>
        string
      </code>
      
      ; <code>
        soon
      </code>
      
      : <code>
        string
      </code>
      
      ; <code>
        credits
      </code>
      
      : { <code>
        month
      </code>
      
      : <code>
        string
      </code>
      
      ; <code>
        year
      </code>
      
      : <code>
        string
      </code>
      
      ; }; <code>
        welcome
      </code>
      
      : <code>
        string
      </code>
      
      ; <code>
        retired
      </code>
      
      : <code>
        string
      </code>
      
      ; <code>
        packCredits
      </code>
      
      : <code>
        string
      </code>
      
      ; <code>
        perCredit
      </code>
      
      : <code>
        string
      </code>
      
      ; <code>
        lessPerCredit
      </code>
      
      : <code>
        string
      </code>
      
      ; <code>
        bestValue
      </code>
      
      : <code>
        string
      </code>
      
      ; <code>
        promotion
      </code>
      
      : { <code>
        once
      </code>
      
      : <code>
        string
      </code>
      
      ; <code>
        months
      </code>
      
      : <code>
        string
      </code>
      
      ; <code>
        forever
      </code>
      
      : <code>
        string
      </code>
      
      ; <code>
        pack
      </code>
      
      : <code>
        string
      </code>
      
      ; <code>
        ends
      </code>
      
      : <code>
        string
      </code>
      
      ; }; <code>
        contact
      </code>
      
      : <code>
        string
      </code>
      
      ; <code>
        subscribe
      </code>
      
      : <code>
        string
      </code>
      
      ; <code>
        switch
      </code>
      
      : <code>
        string
      </code>
      
      ; <code>
        upgrade
      </code>
      
      : <code>
        string
      </code>
      
      ; <code>
        downgrade
      </code>
      
      : <code>
        string
      </code>
      
      ; <code>
        switchInterval
      </code>
      
      : { <code>
        month
      </code>
      
      : <code>
        string
      </code>
      
      ; <code>
        year
      </code>
      
      : <code>
        string
      </code>
      
      ; }; <code>
        scheduled
      </code>
      
      : <code>
        string
      </code>
      
      ; <code>
        cancel
      </code>
      
      : <code>
        string
      </code>
      
      ; <code>
        uncancel
      </code>
      
      : <code>
        string
      </code>
      
      ; <code>
        trial
      </code>
      
      : { <code>
        day
      </code>
      
      : <code>
        string
      </code>
      
      ; <code>
        week
      </code>
      
      : <code>
        string
      </code>
      
      ; <code>
        month
      </code>
      
      : <code>
        string
      </code>
      
      ; <code>
        year
      </code>
      
      : <code>
        string
      </code>
      
      ; }; <code>
        current
      </code>
      
      : <code>
        string
      </code>
      
      ; <code>
        signIn
      </code>
      
      : <code>
        string
      </code>
      
      ; <code>
        signInFree
      </code>
      
      : <code>
        string
      </code>
      
      ; <code>
        returnsToFree
      </code>
      
      : <code>
        string
      </code>
      
      ; <code>
        topUp
      </code>
      
      : <code>
        string
      </code>
      
      ; <code>
        portal
      </code>
      
      : <code>
        string
      </code>
      
      ; <code>
        checkingOut
      </code>
      
      : <code>
        string
      </code>
      
      ; <code>
        changing
      </code>
      
      : <code>
        string
      </code>
      
      ; <code>
        canceling
      </code>
      
      : <code>
        string
      </code>
      
      ; <code>
        uncanceling
      </code>
      
      : <code>
        string
      </code>
      
      ; <code>
        openingPortal
      </code>
      
      : <code>
        string
      </code>
      
      ; <code>
        managed
      </code>
      
      : <code>
        string
      </code>
      
      ; <code>
        finishingPurchase
      </code>
      
      : <code>
        string
      </code>
      
      ; <code>
        confirmTitle
      </code>
      
      : <code>
        string
      </code>
      
      ; <code>
        confirmEnds
      </code>
      
      : <code>
        string
      </code>
      
      ; <code>
        confirmEndsPeriod
      </code>
      
      : <code>
        string
      </code>
      
      ; <code>
        confirmCancel
      </code>
      
      : <code>
        string
      </code>
      
      ; <code>
        changeTitle
      </code>
      
      : <code>
        string
      </code>
      
      ; <code>
        billedAt
      </code>
      
      : { <code>
        month
      </code>
      
      : <code>
        string
      </code>
      
      ; <code>
        year
      </code>
      
      : <code>
        string
      </code>
      
      ; }; <code>
        changeNow
      </code>
      
      : <code>
        string
      </code>
      
      ; <code>
        changeLater
      </code>
      
      : <code>
        string
      </code>
      
      ; <code>
        changeLaterPeriod
      </code>
      
      : <code>
        string
      </code>
      
      ; <code>
        changeTrial
      </code>
      
      : <code>
        string
      </code>
      
      ; <code>
        changeTrialEnds
      </code>
      
      : <code>
        string
      </code>
      
      ; <code>
        changeTrialLater
      </code>
      
      : <code>
        string
      </code>
      
      ; <code>
        changeGifted
      </code>
      
      : <code>
        string
      </code>
      
      ; <code>
        confirmChange
      </code>
      
      : <code>
        string
      </code>
      
      ; <code>
        switchingPlan
      </code>
      
      : <code>
        string
      </code>
      
      ; <code>
        keepCurrent
      </code>
      
      : <code>
        string
      </code>
      
      ; }> | <code>
        undefined
      </code>
      
      >
    </td>
    
    <td>
      Copy for the switch's confirmation (<code>
        change
      </code>
      
      ), over <code>
        appConfig.backend.labels.pricing
      </code>
      
       and the translations.
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/runtime/vue/composables/use-billing-section.ts" rel="nofollow">
        src/runtime/vue/composables/use-billing-section.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="enabled">
        
      </a>
      
       <code>
        enabled?
      </code>
    </td>
    
    <td>
      <code>
        MaybeRefOrGetter
      </code>
      
      <<code>
        boolean
      </code>
      
      >
    </td>
    
    <td>
      While this is <code>
        false
      </code>
      
       no pricing is read for a switch, and none is offered (default <code>
        true
      </code>
      
      ).
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/runtime/vue/composables/use-billing-section.ts" rel="nofollow">
        src/runtime/vue/composables/use-billing-section.ts
      </a>
    </td>
  </tr>
</tbody>
</table>

---

### UseBillingSectionReturn

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

What [useBillingSection](#usebillingsection) returns.

#### Properties

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

<tbody>
  <tr>
    <td>
      <a id="state">
        
      </a>
      
       <code>
        state
      </code>
    </td>
    
    <td>
      <code>
        ComputedRef
      </code>
      
      <<a href="#billingsectionstate">
        <code>
          BillingSectionState
        </code>
      </a>
      
      >
    </td>
    
    <td>
      The state the section shows (see <a href="#billingsectionstate">
        BillingSectionState
      </a>
      
      ).
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/runtime/vue/composables/use-billing-section.ts" rel="nofollow">
        src/runtime/vue/composables/use-billing-section.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 plan is known, unless its read failed, and while a return from checkout is being finished (<code>
        useBilling().isFinishingCheckout
      </code>
      
      ): mark the section busy.
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/runtime/vue/composables/use-billing-section.ts" rel="nofollow">
        src/runtime/vue/composables/use-billing-section.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 pause or a gifted plan's checkout is on its way.
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/runtime/vue/composables/use-billing-section.ts" rel="nofollow">
        src/runtime/vue/composables/use-billing-section.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 plan could not be read, else <code>
        null
      </code>
      
      .
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/runtime/vue/composables/use-billing-section.ts" rel="nofollow">
        src/runtime/vue/composables/use-billing-section.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="actions">
        
      </a>
      
       <code>
        actions
      </code>
    </td>
    
    <td>
      <code>
        ComputedRef
      </code>
      
      <<a href="#billingsectionaction">
        <code>
          BillingSectionAction
        </code>
      </a>
      
      <span>
        
      </span>
      
      >
    </td>
    
    <td>
      What the state calls for, in the order the section offers it: on a failed payment the portal first, then the plan's ways back (resume, keep, cancel the scheduled change), the portal, then a switch, a pause and a cancellation where each is open. A gifted plan's one offer is to keep it. Empty for anyone who does not manage the billing (<code>
        useBilling().canManage
      </code>
      
      ), on the free plan, while loading and after a failed read.
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/runtime/vue/composables/use-billing-section.ts" rel="nofollow">
        src/runtime/vue/composables/use-billing-section.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="switchable">
        
      </a>
      
       <code>
        switchable
      </code>
    </td>
    
    <td>
      <code>
        ComputedRef
      </code>
      
      <<code>
        boolean
      </code>
      
      >
    </td>
    
    <td>
      Whether a switch is offered: a running plan, not gifted, set to end, paused or already changing, with a price to switch to (<code>
        change.targets
      </code>
      
      ).
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/runtime/vue/composables/use-billing-section.ts" rel="nofollow">
        src/runtime/vue/composables/use-billing-section.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="pausable">
        
      </a>
      
       <code>
        pausable
      </code>
    </td>
    
    <td>
      <code>
        ComputedRef
      </code>
      
      <<code>
        boolean
      </code>
      
      >
    </td>
    
    <td>
      Whether a pause is offered: a running plan, not gifted, set to end, paused, past due or in its trial (the provider pauses only an active subscription), and with no pause scheduled (<code>
        resumesAt
      </code>
      
       is <code>
        null
      </code>
      
      ).
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/runtime/vue/composables/use-billing-section.ts" rel="nofollow">
        src/runtime/vue/composables/use-billing-section.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="cancellable">
        
      </a>
      
       <code>
        cancellable
      </code>
    </td>
    
    <td>
      <code>
        ComputedRef
      </code>
      
      <<code>
        boolean
      </code>
      
      >
    </td>
    
    <td>
      Whether a cancellation is offered: a running plan, not gifted, set to end already or paused, which the provider would refuse a second one for.
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/runtime/vue/composables/use-billing-section.ts" rel="nofollow">
        src/runtime/vue/composables/use-billing-section.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="pauselengths">
        
      </a>
      
       <code>
        pauseLengths
      </code>
    </td>
    
    <td>
      readonly <code>
        number
      </code>
      
      <span>
        
      </span>
    </td>
    
    <td>
      The lengths a pause is offered for, in months: <a href="#pause_months">
        PAUSE_MONTHS
      </a>
      
      .
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/runtime/vue/composables/use-billing-section.ts" rel="nofollow">
        src/runtime/vue/composables/use-billing-section.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="resumesafter">
        
      </a>
      
       <code>
        resumesAfter
      </code>
    </td>
    
    <td>
      (<code>
        months
      </code>
      
      ) => <code>
        Date
      </code>
      
       | <code>
        null
      </code>
    </td>
    
    <td>
      When a pause of <code>
        months
      </code>
      
       from the period's end resumes: the period's end moved on by whole months in UTC the way the provider counts them, the same day of the month, or its last when the month is shorter (a period ending January 31 paused for a month resumes February 28). <code>
        null
      </code>
      
       while the period's end is not known.
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/runtime/vue/composables/use-billing-section.ts" rel="nofollow">
        src/runtime/vue/composables/use-billing-section.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="pause">
        
      </a>
      
       <code>
        pause
      </code>
    </td>
    
    <td>
      (<code>
        months
      </code>
      
      ) => <code>
        Promise
      </code>
      
      <<code>
        void
      </code>
      
      >
    </td>
    
    <td>
      Pause the plan from the period's end for <code>
        months
      </code>
      
      , resuming by itself on <code>
        resumesAfter(months)
      </code>
      
      . Rejects as <code>
        useBilling().pause
      </code>
      
       does.
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/runtime/vue/composables/use-billing-section.ts" rel="nofollow">
        src/runtime/vue/composables/use-billing-section.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="keepgifted">
        
      </a>
      
       <code>
        keepGifted
      </code>
    </td>
    
    <td>
      (<code>
        options?
      </code>
      
      ) => <code>
        Promise
      </code>
      
      <<code>
        void
      </code>
      
      >
    </td>
    
    <td>
      Keep a gifted plan: an ordinary checkout of its plan (<code>
        options
      </code>
      
       go with it, <code>
        { redirect: true }
      </code>
      
       by default), which moves the pass to the paid plan in place.
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/runtime/vue/composables/use-billing-section.ts" rel="nofollow">
        src/runtime/vue/composables/use-billing-section.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="change">
        
      </a>
      
       <code>
        change
      </code>
    </td>
    
    <td>
      <a href="https://nuxt-backend.dev/docs/reference/api/use-plan-change#useplanchangereturn">
        <code>
          UsePlanChangeReturn
        </code>
      </a>
    </td>
    
    <td>
      The switch to another plan or billing period, and its confirmation (<code>
        usePlanChange
      </code>
      
      ).
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/runtime/vue/composables/use-billing-section.ts" rel="nofollow">
        src/runtime/vue/composables/use-billing-section.ts
      </a>
    </td>
  </tr>
</tbody>
</table>

## Type Aliases

### PlanState

```ts
type PlanState = typeof PLAN_STATES[number];
```

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

The state a running plan is in: the first of [PLAN_STATES](#plan_states) that holds.

---

### BillingSectionState

```ts
type BillingSectionState = "loading" | "error" | "free" | PlanState;
```

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

The state the billing section shows: `'loading'` until the plan is known,
`'error'` when it could not be read (never a plan it might not be),
`'free'` on the free plan or none, else the running plan's [PlanState](#planstate).

---

### BillingSectionAction

```ts
type BillingSectionAction = 
  | "keep-gifted"
  | "portal"
  | "resume"
  | "uncancel"
  | "cancel-change"
  | "change-plan"
  | "pause"
  | "cancel";
```

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

One thing a billing manager can do with the plan, as the billing section
offers it: keep a gifted plan by checking it out, open the portal (to
update the payment method first when one failed), resume a pause, keep a
plan set to end, cancel a scheduled change, switch the plan or its
billing period, pause it, cancel it.

## Variables

### PLAN_STATES

```ts
const PLAN_STATES: readonly ["gifted", "past_due", "paused", "canceling", "changing", "trialing", "active"];
```

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

The states a running plan can be in, in the order they are tried: the
first that holds is the one shown. A plan pass gifted until its end date,
a failed payment, a pause, a cancellation set for the period's end, a
plan change scheduled for it, a trial, else active. The Subscriptions
page lists them in this order (test/docs pins it).

---

### PAUSE_MONTHS

```ts
const PAUSE_MONTHS: readonly [1, 2, 3];
```

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

The lengths of a pause the section offers, in months from the period's end.

## Functions

### useBillingSection()

```ts
function useBillingSection(options?): UseBillingSectionReturn;
```

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

The billing section of `/settings` without its markup: the state the
plan is in, in the order the section tries them (a gifted plan, a failed
payment, a pause, a cancellation or a plan change set for the period's
end, a trial, else active), a read that failed as a failure rather than
a plan, a return from checkout still finishing as busy, and what each
state calls for, with the rules each offer follows: a switch only while
nothing is scheduled, a pause only while none is, and its resume date
counted the way the provider counts months. `<WorkspaceSettings>`'s
billing section is this with the package's markup.

#### Parameters

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

<tbody>
  <tr>
    <td>
      <code>
        options?
      </code>
    </td>
    
    <td>
      <a href="#usebillingsectionoptions">
        <code>
          UseBillingSectionOptions
        </code>
      </a>
    </td>
  </tr>
</tbody>
</table>

#### Returns

[`UseBillingSectionReturn`](#usebillingsectionreturn)

#### Example

```vue
<script setup lang="ts">
const section = useBillingSection()
// The app's language, not the visitor's, so the server's HTML and the browser's agree.
const { locale } = useLabels('settings')
const day = (date: Date | null) => (date ? new Intl.DateTimeFormat(locale.value ?? 'en', { dateStyle: 'medium' }).format(date) : '')
</script>
<template>
  <section :aria-busy="section.isLoading.value || undefined">
    <p v-if="section.state.value === 'error'" role="alert">The plan could not be read.</p>
    <button v-for="months in section.pausable.value ? section.pauseLengths : []" :key="months" @click="section.pause(months)">
      Pause until {{ day(section.resumesAfter(months)) }}
    </button>
  </section>
</template>
```


## Sitemap

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