Multi-Tenancy
Learn about multi-tenancy in your app.
Multi-tenancy (recommended patterns)
Scoped client (recommended)
const tenantCredit = credit.withTenant("tenant_123");
// All calls from this instance are tenant-scoped automatically
await tenantCredit.request("/some/path");Per-request override (useful for edge cases)
await credit.request("/some/path", {
tenantID: "tenant_override",
});Dynamic tenant resolution (if tenant is in app state)
const credit = createCreditClient({
baseURL: "https://YOUR_BASE_URL",
tenant: {
resolveTenantID: async () =>
window.sessionStorage.getItem("tenant_id") ?? undefined,
},
});