@creem_io/better-auth plugin connects Creem billing to your Better Auth users. It adds
session-aware endpoints for checkout, the customer portal, subscriptions, and transaction history.
With persistence enabled, webhooks keep subscription state in your application database.
Upgrading an existing integration from 1.x? Follow the
migration guide before deploying 2.0.
Quickstart
Install the plugin and complete a subscription checkout.
Configuration
Choose persistence, configure the client, and generate the database schema.
Client API
Create checkouts, open the customer portal, and query billing state.
Webhooks and access
Synchronize subscriptions and run your own access-control logic.
Server API
Call Creem from Server Actions, route handlers, or other trusted code.
Package source
Browse the source, tests, and runnable Next.js example.
What the plugin provides
- Checkout sessions tied to the authenticated user
- Creem customer IDs stored on Better Auth users
- Subscription records synchronized from verified webhooks
- A customer portal for invoices, payment methods, and subscriptions
- Subscription cancellation and retrieval
- Transaction history scoped to the signed-in customer
- High-level callbacks for granting and revoking application access
- One-trial-per-user tracking when persistence is enabled
- Direct server-side helpers when a Better Auth endpoint is not the right fit
Requirements
- A Creem account and API key
- A Better Auth application
- A database supported by Better Auth when using subscription persistence
Test and production environments use different Creem API keys. Start with a test-mode key and set
testMode: true while developing.Choose an integration path
For most applications, use the Better Auth server and client plugins withpersistSubscriptions: true. This gives you session-aware endpoints, automatic customer mapping,
local access checks, and webhook-driven subscription state. Checkout can also run without a
session when you provide the required customer context.
Use the exports from @creem_io/better-auth/server when you need to call Creem directly from
trusted server code. Direct helpers do not infer the signed-in user or automatically persist their
result; your application supplies customer identifiers and enforces authorization.