Skip to main content

Hooks

useCheckEntitlement

Check a single entitlement for a customer.
import { useCheckEntitlement } from "@billingos/sdk";

const { data } = useCheckEntitlement("cus_123", "custom_branding");
// data.has_access: boolean
// data.limit: number | undefined
// data.usage: number | undefined
Parameters:
NameTypeDescription
customerIdstringCustomer ID
featureKeystringFeature key to check

useHasFeature

Boolean shorthand — returns true or false.
import { useHasFeature } from "@billingos/sdk";

const canExport = useHasFeature("cus_123", "export_pdf");

if (canExport) {
  // Show export button
}

useEntitlements

List all entitlements for a customer.
import { useEntitlements } from "@billingos/sdk";

const { data } = useEntitlements("cus_123");

// data: Entitlement[]

useIsApproachingLimit

Returns true when usage is within a threshold of the limit (default: 80%).
import { useIsApproachingLimit } from "@billingos/sdk";

const isNearLimit = useIsApproachingLimit("cus_123", "api_calls", 80);

if (isNearLimit) {
  // Show upgrade nudge
}
Parameters:
NameTypeDefaultDescription
customerIdstringCustomer ID
featureKeystringFeature key
thresholdnumber80Percentage threshold

Entitlement object

interface Entitlement {
  feature_key: string
  has_access: boolean
  limit?: number
  usage?: number
  metadata?: Record<string, string>
}