Better Auth Plugin
Add RevKeen billing, checkout, and customer portal to your Better Auth app
Not yet released. @revkeen/better-auth is not published to npm, so it cannot be installed yet. This page describes the planned plugin and will be updated with install instructions when it is released. To integrate RevKeen today, use the TypeScript SDK directly.
@revkeen/better-auth is a Better Auth plugin for your own Better Auth app. It integrates RevKeen billing into the authentication you already run: it creates RevKeen customers on signup, generates checkout sessions, exposes a customer billing portal, and verifies webhook signatures. It is not related to how you sign in to RevKeen itself.
Server setup
import { betterAuth } from "better-auth";
import { revkeen } from "@revkeen/better-auth";
import { RevKeenClient } from "@revkeen/sdk";
const rk = new RevKeenClient({ apiKey: process.env.REVKEEN_API_KEY! });
export const auth = betterAuth({
// ... your existing config
plugins: [
revkeen({
client: rk,
createCustomerOnSignUp: true,
checkout: {
successUrl: "/thank-you",
cancelUrl: "/pricing",
},
portal: true,
webhooks: {
secret: process.env.REVKEEN_WEBHOOK_SECRET!,
onEvent: {
"payment.succeeded": async (event) => {
console.log("Payment succeeded:", event.data.object);
},
"subscription.cancelled": async (event) => {
console.log("Subscription cancelled:", event.data.object);
},
},
},
}),
],
});Client setup
import { createAuthClient } from "better-auth/client";
import { revkeenClient } from "@revkeen/better-auth/client";
export const authClient = createAuthClient({
plugins: [revkeenClient()],
});Usage
Create a checkout session
const { url } = await authClient.revkeen.checkout({
priceId: "price_xxx",
});
// Redirect to checkout
window.location.href = url;Get customer billing portal data
const portal = await authClient.revkeen.portal();
console.log(portal.subscriptions); // Active subscriptions
console.log(portal.invoices); // Recent invoices
console.log(portal.paymentMethods); // Saved payment methodsHow it works
- On signup — the plugin creates a RevKeen customer via the SDK and stores the customer ID in user metadata
- Checkout —
POST /api/auth/revkeen/checkoutcreates a checkout session tied to the RevKeen customer - Portal —
GET /api/auth/revkeen/portalreturns the customer's subscriptions, invoices, and payment methods - Webhooks —
POST /api/auth/revkeen/webhooksverifies the signature and dispatches to your handlers
Configuration reference
| Option | Type | Default | Description |
|---|---|---|---|
client | RevKeenClient | required | Pre-configured SDK instance |
createCustomerOnSignUp | boolean | true | Auto-create RevKeen customer on signup |
checkout.successUrl | string | — | Default redirect after payment |
checkout.cancelUrl | string | — | Default redirect on cancel |
portal | boolean | false | Enable customer portal endpoint |
webhooks.secret | string | — | Webhook signing secret |
webhooks.onEvent | Record<string, handler> | — | Event handlers by type |
Next Steps
Authentication
API key and OAuth authentication reference.
Webhooks
Webhook event types and delivery details.
TypeScript SDK
Full SDK reference for server-side integrations.
Owner: david · Reviewed 30 Sep 2026 · Next review 29 Dec 2026