Server options
Pass these options tocreem() in your Better Auth configuration:
Webhook callback options are covered in Webhooks and access.
lib/auth.ts
Persistence mode
Persistence is enabled unless you explicitly setpersistSubscriptions: false. The plugin then:
- adds its models and fields to the Better Auth schema;
- associates a Creem customer ID with the signed-in user;
- writes subscription state received through verified webhooks;
- checks local subscription records in
hasAccessGranted(); - records whether a user has already received a trial.
Added models and fields
Thecreem_subscription model contains:
The plugin extends the Better Auth
user model with:
Without persistence
SetpersistSubscriptions: false when your application owns subscription storage or does not need
local billing state:
hasAccessGranted() cannot
determine access in this mode, so implement access checks in your own data layer. Other endpoints
can still call Creem, provided they receive or can resolve the required customer or subscription
identifier.
Client options
The standard Better Auth client infers the Creem endpoints fromcreemClient():
lib/auth-client.ts
baseURL is optional when the client calls the same origin. Use Better Authβs client import for
your framework, such as better-auth/react for React.
If TypeScript does not expose clean method signatures for an inferred client, use the typed wrapper:
lib/auth-client.ts