Two decision types
- Feature gates — boolean access, such as analytics or SSO.
- Usage limits — numeric caps, such as monthly requests or generated reports.
Server-side enforcement
can() immediately before protected work. The response can include usage and margin context in addition to the allow/deny decision.
React presentation
Fetch entitlement state through your authenticated backend and pass it into presentational gates:Updates
Refresh entitlement state after checkout, subscription, or usage changes. For push-based updates, issue a separate server-authorized realtime token or publish through your own authenticated channel. Never sendpk_ or sk_ credentials to a browser WebSocket connection.
Margin-aware decisions
can() can return unit cost, revenue, margin, thresholds, and warnings. Use those fields for observability or merchant-defined policy without exposing them to customers unless required.