Skip to main content

Server options

Pass these options to creem() in your Better Auth configuration: Webhook callback options are covered in Webhooks and access.
lib/auth.ts
testMode defaults to false. Do not pair a test API key with production mode or a production API key with test mode.

Persistence mode

Persistence is enabled unless you explicitly set persistSubscriptions: 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.
After enabling persistence or upgrading to a version that changes the schema, use the command for your database workflow. The built-in Kysely adapter can apply the migration directly:
For Prisma, Drizzle, or another ORM-managed schema, generate the schema and then apply it with the ORM’s migration tooling:

Added models and fields

The creem_subscription model contains: The plugin extends the Better Auth user model with:

Without persistence

Set persistSubscriptions: false when your application owns subscription storage or does not need local billing state:
No plugin schema is added and no subscription records are written. 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 from creemClient():
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
The wrapper is optimized for the Creem plugin. Prefer the standard client when combining many Better Auth client plugins, and use the wrapper only when its improved Creem types are useful.