Skip to main content
CreditBalance shows how many credits a customer has in one credit system, and the grants and top-ups they come from. From React 0.11.0. When to use
  • Next to an AI or credit-metered feature, so customers see what is left.
  • The credits section of your billing settings, with CreditHistory below it.
  • Any place that shows what remains of each grant or top-up and when it expires.
CreditBalance with 1,240 AI credits from a plan grant and a top-up, light theme

Importing CreditBalance

Rendering CreditBalance

Inside a BillingProvider with billingEndpoint, read the balance with useCreditBalance and pass it in:
app/billing/credits/page.tsx
The card shows the available credits with the unit name, singular for exactly 1 (“1 credit available”, “1,240 credits available”), and “As of <date>” for the time of the reading. Below it, one line per source shows what remains and when it expires.

Data

balance is a CreditBalanceData. Credit amounts are decimal strings.

Live data

Inside a BillingProvider with billingEndpoint, useCreditBalance(creditSystemCode?) returns one balance of the signed-in customer: the given credit system, else the first one with credits, else the first one.
Without the hooks, pass one entry of the SDK’s credits.balance result, read on your backend.

Source types

Each source’s type sets its label. A source type the component does not know shows as sent. Sources whose remaining is "0" are hidden.

Examples

Loading, empty and error

isLoading shows a loading placeholder, no balance shows emptyMessage, and error shows the message as an alert.
CreditBalance loading placeholder, No credit balance yet message, and an error message, light theme

API reference

CreditBalanceData | null
null or no value shows the empty message.
boolean
default:false
Shows a loading placeholder.
Error | string | null
Shows the message as an alert. Defaults to null.
string
default:"No credit balance yet."
Shown when there is no balance.
Appearance
Theme, variables and element overrides. Defaults to the provider’s. See Appearance.
Dates show in en-US (“Oct 16, 2026”).

States

Appearance

creditBalance (root), creditBalance__amount (the large number).Style them with appearance.elements. See Elements.

CreditHistory

How credits were used and granted.

Credits

How credit systems work.