Skip to main content
The @creem_io/better-auth/server entry point provides direct Creem helpers for code that does not need to go through a Better Auth endpoint.
These helpers use your secret API key and must run on the server. They do not automatically infer the signed-in user. Authenticate the request and authorize every customer or subscription ID before calling them.

Configure the environment

Create a checkout

Unlike the client endpoint, the direct helper requires customer information because it has no Better Auth session to inspect.

Open the customer portal

Verify that the stored customer ID belongs to the authenticated account.

Manage subscriptions

Search transactions

Create a raw SDK client

Use createCreemClient() when the helper functions do not cover the API operation you need:
For general SDK coverage, see the TypeScript SDK documentation.

Utility functions

The server entry point also exports: checkSubscriptionAccess() and getActiveSubscriptions() are also exported, but their database mode expects a raw query-builder interface that is not compatible with every Better Auth adapter. Prefer the authenticated hasAccessGranted() endpoint or query your own database through its supported adapter API. These server helpers only recognize active, trialing, and paid; they do not evaluate scheduled cancellation deadlines or payment grace periods. Use hasAccessGranted() for those access decisions.

Call Better Auth endpoints on the server

Calls through auth.api use the same endpoints as the browser client. Pass the current request’s headers for session authentication. Unlike browser client results, failed direct calls throw a Better Auth APIError:
Pass asResponse: true when you need an HTTP Response instead. Check response.ok and response.status; error JSON contains message, replacing the previous error field. This applies to checkout, portal, cancel, retrieve, transaction search, and access endpoints. The direct helpers from @creem_io/better-auth/server keep their separate behavior.