Skip to main content
@usenarrator/plugin-autumn-js The Autumn plugin reads autumn-js calls the way Autumn’s docs explain them. A check asks whether the customer can use a feature, a track records uses of it, and attach gives the customer a plan. Each line names the customer, the feature and the plan, so autumn.check({ customerId: "user_123", featureId: "messages" }) reads as “Check whether the customer “user_123” can use the messages feature”. A check’s answer, kept as allowed, res.allowed or 0.x’s data.allowed, reads as that same question wherever it’s tested.
The plugin declares library: { name: "autumn-js", versions: ">=0.1 <2" }. It reads both majors: 1.x’s camelCase parameters and namespaces (billing.attach, customers.getOrCreate, plans) and 0.x’s snake_case parameters, { data, error } results, products and static Autumn.check(…). Same-named calls kept their meaning between the two, so there is no version option. It only narrates files that import autumn-js or belong to a package that depends on it (see Dependency detection), and only calls on something it can show is an Autumn client: a new Autumn(…), a value typed Autumn, the Autumn class, or an autumn the file imports from the app’s own module. Another SDK’s autumn.attach(…), a Stripe call and a useCustomer from elsewhere are left alone.

Examples

Checking and tracking
English
Plans and billing
English
A backend handler
English
React hooks
English

What it covers

  • The client: new Autumn with its secret key (or the AUTUMN_SECRET_KEY it falls back to), server URL and fail-open setting.
  • check with requiredBalance, sendEvent, lock, entities, event properties and withPreview; its answer as a condition, its balance, and 0.x’s { data, error }.
  • track, negative values, event names, async: false, idempotency keys, trackTokens and batchTrack; setting usage directly with balances.update or 0.x usage; granting balances and finishing locks with balances.finalize.
  • Billing: attach, multiAttach, previews, 0.x checkout, billing.update with its cancel actions and quantities, 0.x cancel, the billing portal and payment setup, with trials, prepaid quantities, proration, discounts and redirects as bullets. The payment, checkout and portal URLs on the results read as what they open.
  • Customers (getOrCreate, get, update with billing controls, delete, 0.x create and updateBalances), entities in both call styles, plans, products, features, referrals, rewards, licenses and usage totals (events.aggregate, 0.x query). Invoices, webhooks, keys and sandboxes read by method.
  • autumnHandler from every framework adapter, with how it identifies the customer, and the low-level handler from autumn-js/backend.
  • React: useCustomer and the functions it hands back (attach, checkout, check, track, cancel, updateSubscription, openBillingPortal, openCustomerPortal, setupPayment, refetch and the rest), useEntity, usePricingTable, useListPlans, useReferrals, useListEvents, useAggregateEvents and usePaywall. Components such as PricingTable and CheckoutDialog are read by the React plugin like any other component.
  • Better Auth’s autumn() plugin is read by the Better Auth plugin.

Translating

The English phrasebook is exported as en and typed as AutumnPhrases.