The client plugin exposes billing methods under authClient.creem. Requests include the current
Better Auth session when one is available. Portal, subscription, transaction, and access endpoints
require a signed-in user; checkout can also be created without a session.
The plugin infers endpoint inputs, successful responses, and Creem session fields through Better Auth. The
createCreemAuthClient wrapper remains exported for compatibility but is deprecated.
Every method returns the Better Auth { data, error } result shape. Handle error before using
data. A failed request returns data: null and an error containing message, status, and
statusText; successful response types do not contain an error alternative.
Creem session fields are inferred when persistence is enabled. If the server uses
persistSubscriptions: false, configure creemClient({ persistSubscriptions: false }) too.
The client option controls inference; it does not change the server configuration.
Create a checkout
Navigation is manual by default (redirect: false). Set redirect: true to let Better Auth
redirect to the checkout URL automatically.
customField is a deprecated alias for customFields. New code should use customFields.
Open the customer portal
To redirect automatically, use await authClient.creem.createPortal({ redirect: true }).
The default is redirect: false, which returns the URL for manual navigation.
With persistence enabled, omit customerId so the plugin uses the current user’s stored
creemCustomerId. The endpoint also accepts an explicit customer ID, but it does not verify that
the ID belongs to the signed-in user. Do not pass a value obtained from untrusted client input.
Check access
hasAccessGranted() reads the signed-in user’s persisted subscriptions. It grants access for
active, trialing, or paid records. A scheduled_cancel, past_due, or unpaid subscription also
retains access while its periodEnd is still in the future, so customers can use time they have
already paid for. A canceled subscription no longer grants access.
On success, data.hasAccessGranted is a boolean. A signed-out request returns an error with status
401, disabled persistence returns 400, and a failed database check returns 500. These failures
return data: null, so check error before reading the access result. Do not grant access when the
check fails.
Cancel a subscription
The published client type requires the subscription ID. The endpoint does not consistently verify
ownership of caller-supplied IDs, so derive the ID from billing state already authorized for the
signed-in user. Use the returned success and message fields to update the interface.
Retrieve a subscription
The result includes the subscription status, customer, product, billing dates, and metadata.
Customer and product values can be IDs or expanded objects; narrow their types before reading
object properties. Dates returned over HTTP are serialized values, so convert them with new Date()
when you need date methods instead of assuming a JavaScript Date instance.
As with cancellation, do not accept the subscription ID from an untrusted caller without checking
that it belongs to the signed-in account.
Search transactions
The response contains data.items and data.pagination; it does not expose the SDK page iterator.
Available filters are customerId, productId, orderId, pageNumber, and pageSize. When
customerId is omitted, the endpoint uses the customer associated with the signed-in user. Prefer
that default: an explicit customer ID is not checked against the current user.
Type exports
Client input and result types can be imported from the package root or client entry point: