Client
The typed client plugin and every method it adds to authClient.
import { createAuthClient } from "better-auth/react"; // or better-auth/client
import { organizationClient } from "better-auth/client/plugins";
import { nuvionClient } from "@umohpyro/better-auth-nuvion/client";
export const authClient = createAuthClient({
plugins: [organizationClient(), nuvionClient()],
});nuvionClient() infers its types from the server plugin, so request bodies and responses are checked by tsc. A wrong type is a compile error.
| Method | Calls |
|---|---|
authClient.nuvion.organization.parent({ organizationId, parentOrganizationId }) | Set a parent |
authClient.nuvion.organization.bind({ organizationId, entityId, accountId }) | Bind to Nuvion |
authClient.nuvion.organization.destinations({ organizationId }) | Provision counterparties |
authClient.nuvion.feeRule({ organizationId, bps, flatMinor, minMinor, capMinor, bearer }) | Set a fee rule |
authClient.nuvion.payments({ organizationId, amountMinor, currency, redirectUrl }) | Create a payment |
authClient.nuvion.payments.retry({ paymentId }) | Retry |
authClient.nuvion.payments.refund({ paymentId }) | Refund |
Every method returns Better Auth's usual { data, error }:
const { data, error } = await authClient.nuvion.payments({
organizationId: merchant.id,
amountMinor: 10_000,
currency: "GBP",
redirectUrl: "https://shop.example.com/done",
});
if (error) return toast(error.message);
window.location.href = data.checkoutUrl;Typing the server
The client needs the server plugin's type. Keep lib/auth.ts importable from the client's type context (a type-only import is enough) and run tsc --noEmit in CI so a wrong call fails the build.