Skip to main content
This page is the exhaustive reference. For task-shaped guides start with the Quickstart and its siblings.

Backend API

Resource namespaces: creem.<namespace>.*

All methods take explicit arguments. Use them directly in your own Convex functions, or let creem.api({ resolve }) generate ready-to-export wrappers. creem.subscriptions.* Set new Creem(components.creem, { cancelMode: "scheduled" }) to make normal cancel actions end at the paid period boundary and surface subscription.scheduled_cancel. Pass revokeImmediately on an individual cancel call when you need to override that default. creem.checkouts.* creem.products.* creem.customers.* creem.orders.* creem.credits.* Entity-scoped methods are the preferred backend API. They resolve the default credit account from a trusted billing entity and keep provider account IDs out of client arguments. Do not export the raw primitives directly as public Convex actions. Composite helpers (top-level methods)

creem.api({ resolve }) convenience exports

Generates ready-to-export Convex function definitions. Each function calls your resolve callback, then delegates to the corresponding namespace method. creem.api() does not generate public credit-account creation, credit, or debit actions. Those operations must stay behind app-owned backend functions. Every generated function declares a real Convex returns validator, so Convex clients infer the concrete result type instead of any. The matching TypeScript types are derived from those validators with Infer<>, which is why ConnectedBillingApi can pin each reference’s return type and reject a mis-wired export at compile time. snapshot and creem.getBillingSnapshot(...) return the backend billing snapshot:
Mental model:
  • subscriptions mirrors Creem recurring subscriptions and supports multiple simultaneous rows, such as a base subscription plus add-ons.
  • orders mirrors Creem orders. Subscription checkouts also create orders, but the snapshot only exposes one-time orders as owned one-time access.
  • appPlanAssignments stores Convex-Creem-owned current or scheduled app-owned plans such as free plans, no-card trials, and custom internal plans.
  • access is a derived read model that combines active subscriptions, paid one-time orders, and active app-plan assignments. It is not a separate table and should not be treated as the source of truth.

Infrastructure

Direct API access with creem.sdk.*

The resource namespaces above cover all billing features that stay in sync with Convex via webhooks. Some Creem API resources have no webhook support, so the component cannot mirror them in Convex DB. For these, use creem.sdk.* directly inside your own Convex actions. It is the same Creem SDK client, already configured with your API key:

Component Reference

All components share identical props across Svelte and React.
  • Import: @creem_io/convex/svelte or @creem_io/convex/react
  • CSS class prop: class in Svelte, className in React
  • Children: Svelte Snippet / React ReactNode
  • Svelte components use Svelte 5 runes and snippet rendering ({@render ...})
See the Svelte example and React example for complete integrations. The components below read the provider and talk to Convex directly. Everything under Billing state components, plus <CheckoutButton> below, takes plain props instead.

<CreemConvexProvider>

Required context boundary for connected widgets. Render it around any Subscription, Product, BillingPortal, BillingHistory, or Credits widgets. Connected widgets no longer accept direct api={...} props. Pass the API to CreemConvexProvider once. createCreemReact / createCreemSvelte return a spreadable binding: <CreemConvexProvider {...billing}>.

<Subscription>

The subscription namespace. Subscription.Root owns billing state and actions; everything else registers a plan or renders a slot inside it. It is a plain namespace object, so render <Subscription.Root> or <Subscription.Item>, never a bare <Subscription>.

<Subscription.Root>

Container for subscription plan cards. Handles billing cycle toggle, checkout, plan switching, cancellation, and unit management. Use unstyled when composing your own pricing cards with Subscription.Grid, Subscription.ItemTitle, Subscription.ItemPrice, Subscription.ItemDescription, Subscription.ItemBadge, Subscription.ItemCTA, Subscription.ItemPriceCaption, Subscription.UnitPicker, Subscription.Cancel, Subscription.GroupSelector, or Subscription.IntervalSelector. The default generated pricing cards remain the fast styled path. Styled compound defaults use the package’s creem-base: Tailwind variant, which places library defaults in the base cascade layer. Consumer class/className utilities like font-bold, text-xl, or bg-emerald-600 therefore override the built-in defaults without tailwind-merge. UpdateBehavior controls paid subscription updates:
  • "proration-charge-immediately" prorates and charges the difference now. This is the default.
  • "proration-charge" prorates and charges on the next invoice.
  • "proration-none" skips proration; the change takes effect on the next billing cycle.
  • "period-end" keeps the current subscription active until currentPeriodEnd, then applies the target plan or unit count from a scheduled Convex job.
The first three values map directly to Creem’s paid subscription update behavior. updateBehavior intentionally does not include "immediate" because Creem paid-to-paid switches cannot be immediate cancellation. AppPlanUpdateBehavior controls paid-to-app-owned target switches:
  • "period-end" schedules Creem cancellation for the billing period boundary, then activates the app-owned target plan at that time. This is the default.
  • "immediate" calls Creem cancellation with mode: "immediate" and assigns the app-owned plan straight away.
Paid-to-app-owned is a cancellation flow because the target entitlement is fulfilled by your app rather than Creem. Use appPlanUpdateBehavior, not updateBehavior, when you want to choose between period-end and immediate cancellation. Until Creem supports native scheduled subscription updates, the Creem customer portal will still show the current subscription as active and will not know about pending app-side paid-to-free assignment. Use a resolver function when upgrades and downgrades should behave differently:

<Subscription.Item>

Registers a plan inside <Subscription.Root>. Without children it registers only, and the root renders the default pricing card. With children it becomes the card wrapper and provides the item context that every Subscription.Item* slot reads. Slots placed outside an item throw. Supported billing cycles: every-month, every-three-months, every-six-months, every-year.

<Subscription.Grid>

Layout wrapper for custom composed subscription cards.

<Subscription.Group>

Conditional group wrapper for custom composed subscription sections.

<Subscription.GroupSelector>

Group selector for groupSelector="external" composition.

<Subscription.IntervalSelector>

Billing-cycle selector for intervalSelector="external" composition.

<Subscription.ItemPriceCaption>

Secondary price text for inherited unit quantities, such as $30/mo × 3 units. Pair it with <Subscription.ItemPrice> when a custom card should show the total bill as the primary price and the unit calculation as supporting text.

<Subscription.ItemTitle>, <Subscription.ItemPrice>, and <Subscription.ItemDescription>

Text slots for custom subscription cards. Each resolves its value from the current Subscription.Item context. Subscription.ItemPriceCaption accepts the same class/className prop.

<Subscription.UnitPicker>

Composable quantity control for unit-based plans. Use it inside a custom <Subscription.Item> when your card owns the markup. For inactive unit plans it updates the checkout quantity; for the active unit plan it renders the change/update flow when subscription unit updates are available. Pass detailed to also show the current subscribed quantity above the change button. It returns null on switch-plan cards so the current subscribed quantity is not mistaken for a target quantity. In unstyled mode, pass class/className plus slot classes such as rowClass, labelClass, actionsClass, secondaryClass, primaryClass, and numberInputClass in Svelte. React uses the same names with Name suffixes, for example rowClassName and primaryClassName.

<Subscription.ItemCTA>

Composable subscription action button.

<Subscription.ItemBadge>

Composable badge for current/recommended/custom plan labels.

<Subscription.Cancel>

Composable cancel button for the active subscription card. It opens the same root-owned confirmation dialog as the default pricing card, and renders nothing when the card is not active or cancellation is unavailable.

<Product>

The one-time and repeating product namespace. Product.Root owns ownership tracking, upgrade transitions, and checkout; Product.Item registers a product inside it.

<Product.Root>

Container for one-time or repeating product cards. Handles ownership tracking, upgrade transitions, and checkout. Transition types:

<Product.Item>

Registers a product inside <Product.Root>.

<BillingPortal>

Button that opens the Creem customer billing portal. Auto-hides when the billing entity has no Creem customer record, or when canAccessPortal is false.

<BillingHistory>

Paginated transaction history backed by Creem’s transaction search endpoint. This renders transaction rows only. Invoice and receipt documents are not included in this component. Add the generated transaction action to your connected API:

<Credits>

The customer-credits namespace. Credits.Root loads the balance and provides context; the remaining pieces are display slots you compose inside it.

<Credits.Root>

Credit balance widget backed by the provider’s credits.getBalance action.

<Credits.Title>

<Credits.Amount>

<Credits.Refresh>

<Credits.Error> and <Credits.Status>

Display credit API errors or loading/status text. Both accept class/className.

Billing state components

Fed from the billing snapshot rather than the provider. Use them to surface lifecycle states anywhere in your app, including outside CreemConvexProvider.

<BillingGate>

Conditionally renders children based on available billing actions.

<CheckoutSuccessSummary>

Displays a success banner after checkout. Parses Creem query params automatically. React also exports a useCheckoutSuccessParams() hook that returns the parsed params directly.

<ScheduledChangeBanner>

Shows a scheduled cancellation or app-side period-end update notice. In a connected provider, pass subscriptionId and the widget derives the current period, scheduled update, target label, undo/resume handlers, and i18n from the billing model.

<PaymentWarningBanner>

Shows a warning for pending, refunded, or partially refunded payments.

<TrialLimitBanner>

Page-level notice that the entity is on a trial. Subscription.Root already shows a countdown badge on the active plan card, so use this banner where no pricing card renders, such as an app shell or dashboard header. Renders nothing when no subscription is trialing.

<CheckoutButton>

Standalone checkout button for places that have no pricing card: a nav bar, a marketing page, an in-app upsell. It reads no provider context, so it works anywhere; you supply the product and handle the checkout call.
Marketing page
Inside a Subscription.Root or Product.Root, use Subscription.ItemCTA or let the default cards render instead. Those are wired to the root’s checkout flow, including the guards and permission flags.

Troubleshooting