Skip to main content

@amisi-mobile-starter/subscriptions

@amisi-mobile-starter/subscriptions provides mock and revenuecat adapters, provider-backed state, entitlement hooks, and a RevenueCat UI paywall.

Initialize RevenueCat

RevenueCatSubscriptionsOptions has iosApiKey?, androidApiKey?, apiKey?, appUserId?, useAmazon?, logLevel?, and entitlementId?. apiKey takes precedence. Otherwise the adapter selects the matching iOS or Android key. It throws when no key is available. RevenueCatLogLevel is keyof typeof LOG_LEVEL from react-native-purchases.

Add the provider

config is optional. When omitted, the provider uses an adapter initialized elsewhere. Context contains adapter, status, products, loading, purchase(productId), restore(), and refresh(). Both useSubscriptions() and its useSubscription() wrapper require SubscriptionsProvider.

Entitlement hooks

useEntitlement(productId) checks status.isActive and exact equality with status.productId. Passing an empty string checks only active status. The argument is required.

Data types

SubscriptionProduct contains required id, name, price, currency, and period, plus optional features. Period is monthly | yearly | lifetime. SubscriptionStatus contains required isActive, plus optional productId, expiresAt, willRenew, and platform. Platform is ios | android | web.

RevenueCat paywall

Paywall renders RevenueCatUI.Paywall and requires the active adapter’s name to be revenuecat. Otherwise it throws.
The exact props are:
There are no onPurchase, onRestore, or onClose props. The imperative exports are:

Custom adapters

Implement SubscriptionAdapter, then register the adapter instance: