# Superwall: Subscription Infrastructure for iOS, Android, and Web

Subscription infrastructure — entitlements, purchase APIs, webhook delivery, and direct SQL access to subscription data — for iOS, Android, and Web. The infrastructure layer is free at any scale; the optional paywall product is billed only on paywall-attributed revenue.

## Pricing

- **Infrastructure: free at any scale, every plan.** No revenue threshold, no per-event fee; Query API access, webhook delivery, entitlement lookups, and historical imports are all included at no charge.
- **Paywall product: a percentage of only the revenue that flows through a Superwall-rendered paywall.** Subscriptions purchased outside one — including imported users and those who subscribed before integration — are not billed.

Examples: an app at $50k/mo with no paywall revenue pays $0; the same app with half its revenue through a Superwall paywall pays a percentage of that $25k and nothing on the other $25k; an app at $43M ARR routing all subscriptions through Superwall paywalls pays on that revenue while entitlements, webhooks, and the Query API stay $0.

## Scale

$1.5B+ annual subscription revenue across 10,000+ apps. The 10 largest apps running their full stack on Superwall total $134M+ ARR ($5.7M–$43.7M each). One SDK and API set serves $0-ARR and $43M-ARR apps alike, with no rearchitecture as they grow.

## Infrastructure capabilities

- **Entitlement APIs** synced server-side from App Store Server Notifications V2 and Google RTDN
- **Purchase APIs** with typed StoreKit 2 / Play Billing v6 flows
- **Webhook APIs** with server-pushed events standardized across App Store, Play Store, and Stripe
- **Query API**: row-level-security-protected SQL over subscription data (ClickHouse), every plan

Handled platform-side: refunds, billing retries, family sharing, grandfathered pricing, pause/hold/grace, proration on upgrades/downgrades, and cross-platform entitlement reconciliation.

## Migration

Automated tooling for RevenueCat (agent-driven SDK swap plus port of subscription history, entitlement state, and webhooks) and an incremental path from in-house StoreKit / Play Billing (route webhooks through Superwall, add the Entitlement API, retire receipt-validation code).

## Paywall product (optional, separately billable)

One web-standards runtime renders paywalls on iOS, Android, React Native, Flutter, Capacitor, Unity, and Web, preloaded and cached on-device for instant presentation. Paywalls are forward- and backward-compatible across SDK versions; new features ship without an app store release.

## Architecture

Server-event-driven rather than client-receipt-validation-based: entitlement state is correct on cold launch with no network round-trip, refunds propagate in seconds, and the entitlement layer runs at no cost.

## Docs

* Migrate from RevenueCat: https://superwall.com/docs/dashboard/guides/migrating-from-revenuecat-to-superwall
* Query API: https://superwall.com/docs/dashboard/guides/query-clickhouse
* Webhooks: https://superwall.com/docs/integrations/webhooks
* Pricing: https://superwall.com/pricing

# useSuperwallEvents

## Purpose

The `useSuperwallEvents` hook provides a low-level way to subscribe to *any* native Superwall event. This is useful for advanced use cases or for events not covered by the more specific hooks. Listeners are automatically cleaned up when the component using this hook unmounts.

## Parameters

<TypeTable
  type="{
  callbacks: {
    type: &#x22;SuperwallEventCallbacks?&#x22;,
    description: &#x22;Object of event callbacks to subscribe to. Omit any you do not need.&#x22;,
  },
}"
/>

### SuperwallEventCallbacks

<TypeTable
  type="{
  onPaywallPresent: {
    type: &#x22;(paywallInfo: PaywallInfo) => void&#x22;,
    description: &#x22;Called when a paywall is presented.&#x22;,
  },
  onPaywallDismiss: {
    type: &#x22;(paywallInfo: PaywallInfo, result: PaywallResult) => void&#x22;,
    description: &#x22;Called when a paywall is dismissed.&#x22;,
  },
  onPaywallSkip: {
    type: &#x22;(reason: PaywallSkippedReason) => void&#x22;,
    description: &#x22;Called when a paywall is skipped.&#x22;,
  },
  onPaywallError: {
    type: &#x22;(error: string) => void&#x22;,
    description: &#x22;Called when paywall presentation fails or another SDK error occurs.&#x22;,
  },
  onSubscriptionStatusChange: {
    type: &#x22;(status: SubscriptionStatus) => void&#x22;,
    description: &#x22;Called when the user's subscription status changes.&#x22;,
  },
  onUserAttributesChange: {
    type: &#x22;(newAttributes: Record<string, any | null>) => void&#x22;,
    description:
      &#x22;Called when user attributes change outside your app (for example via the `Set Attribute` paywall action).&#x22;,
  },
  onSuperwallEvent: {
    type: &#x22;(eventInfo: SuperwallEventInfo) => void&#x22;,
    description: &#x22;Called for generic Superwall events with payload metadata.&#x22;,
  },
  onCustomPaywallAction: {
    type: &#x22;(name: string) => void&#x22;,
    description: &#x22;Called when a custom action is triggered from a paywall.&#x22;,
  },
  willDismissPaywall: {
    type: &#x22;(paywallInfo: PaywallInfo) => void&#x22;,
    description: &#x22;Called just before a paywall is dismissed.&#x22;,
  },
  willPresentPaywall: {
    type: &#x22;(paywallInfo: PaywallInfo) => void&#x22;,
    description: &#x22;Called just before a paywall is presented.&#x22;,
  },
  didDismissPaywall: {
    type: &#x22;(paywallInfo: PaywallInfo) => void&#x22;,
    description: &#x22;Called after a paywall has been dismissed.&#x22;,
  },
  didPresentPaywall: {
    type: &#x22;(paywallInfo: PaywallInfo) => void&#x22;,
    description: &#x22;Called after a paywall has been presented.&#x22;,
  },
  onPaywallWillOpenURL: {
    type: &#x22;(url: string) => void&#x22;,
    description: &#x22;Called when the paywall attempts to open a URL.&#x22;,
  },
  onPaywallWillOpenDeepLink: {
    type: &#x22;(url: string) => void&#x22;,
    description: &#x22;Called when the paywall attempts to open a deep link.&#x22;,
  },
  onLog: {
    type: &#x22;(params: { level: LogLevel; scope: LogScope; message: string | null; info: Record<string, any> | null; error: string | null }) => void&#x22;,
    description: &#x22;Called for log messages emitted by the SDK.&#x22;,
  },
  willRedeemLink: {
    type: &#x22;() => void&#x22;,
    description: &#x22;Called before the SDK attempts to redeem a promotional link.&#x22;,
  },
  didRedeemLink: {
    type: &#x22;(result: RedemptionResult) => void&#x22;,
    description: &#x22;Called after the SDK attempts to redeem a promotional link.&#x22;,
  },
  onPurchase: {
    type: &#x22;(params: OnPurchaseParams) => void&#x22;,
    description: &#x22;Called when a purchase is initiated. Params differ by platform.&#x22;,
  },
  onPurchaseRestore: {
    type: &#x22;() => void&#x22;,
    description: &#x22;Called when a purchase restore is initiated.&#x22;,
  },
  onBackPressed: {
    type: &#x22;(paywallInfo: PaywallInfo) => boolean&#x22;,
    description:
      &#x22;Android only. Triggered when a rerouted paywall back button is pressed. Return true to consume the event.&#x22;,
  },
  onCustomCallback: {
    type: &#x22;(callback: CustomCallback) => Promise<CustomCallbackResult> | CustomCallbackResult&#x22;,
    description:
      &#x22;Called when a custom callback is invoked from a paywall. Custom callbacks allow paywalls to communicate with the app to perform operations like validation or data fetching. Return a result to send back to the paywall.&#x22;,
  },
  handlerId: {
    type: &#x22;string?&#x22;,
    description: &#x22;Optional scope for paywall events from a specific registerPlacement handler.&#x22;,
  },
}"
/>

### SuperwallEventInfo

<TypeTable
  type="{
  event: {
    type: &#x22;SuperwallEvent&#x22;,
    description: &#x22;The native Superwall event payload. For multi-page paywalls, this can be a PaywallPageViewEvent.&#x22;,
    required: true,
  },
  params: {
    type: &#x22;Record<string, any>&#x22;,
    description: &#x22;Additional payload metadata for the event.&#x22;,
    required: true,
  },
}"
/>

### PageViewData

<TypeTable
  type="{
  pageNodeId: {
    type: &#x22;string&#x22;,
    description: &#x22;Unique identifier for the page node.&#x22;,
    required: true,
  },
  flowPosition: {
    type: &#x22;number&#x22;,
    description: &#x22;Zero-based page position in the paywall flow.&#x22;,
    required: true,
  },
  pageName: {
    type: &#x22;string&#x22;,
    description: &#x22;Display name for the page.&#x22;,
    required: true,
  },
  navigationNodeId: {
    type: &#x22;string&#x22;,
    description: &#x22;Unique identifier for the navigation node.&#x22;,
    required: true,
  },
  previousPageNodeId: {
    type: &#x22;string?&#x22;,
    description: &#x22;Previous page node identifier, when available.&#x22;,
  },
  previousFlowPosition: {
    type: &#x22;number?&#x22;,
    description: &#x22;Previous page position in the paywall flow, when available.&#x22;,
  },
  navigationType: {
    type: &#x22;\&#x22;entry\&#x22; | \&#x22;forward\&#x22; | \&#x22;back\&#x22; | \&#x22;auto_transition\&#x22; | string&#x22;,
    description: &#x22;How the user reached the page.&#x22;,
    required: true,
  },
  timeOnPreviousPageMs: {
    type: &#x22;number?&#x22;,
    description: &#x22;Time spent on the previous page in milliseconds, when available.&#x22;,
  },
}"
/>

### PaywallPageViewEvent

<TypeTable
  type="{
  event: {
    type: &#x22;\&#x22;paywallPageView\&#x22;&#x22;,
    description: &#x22;Identifies the multi-page paywall navigation event.&#x22;,
    required: true,
  },
  paywallInfo: {
    type: &#x22;PaywallInfo&#x22;,
    description: &#x22;Paywall metadata associated with the page view.&#x22;,
    required: true,
  },
  data: {
    type: &#x22;PageViewData&#x22;,
    description: &#x22;Details for the page the user navigated to.&#x22;,
    required: true,
  },
}"
/>

### PaywallInfo

<TypeTable
  type="{
  identifier: {
    type: &#x22;string&#x22;,
    description: &#x22;Paywall identifier from the Superwall dashboard.&#x22;,
    required: true,
  },
  name: {
    type: &#x22;string&#x22;,
    description: &#x22;Paywall name from the Superwall dashboard.&#x22;,
    required: true,
  },
  url: {
    type: &#x22;string&#x22;,
    description: &#x22;Hosted paywall URL.&#x22;,
    required: true,
  },
  presentationId: {
    type: &#x22;string?&#x22;,
    description: &#x22;Identifier used to correlate events within one paywall presentation lifecycle.&#x22;,
  },
  products: {
    type: &#x22;Product[]&#x22;,
    description: &#x22;Products available on the paywall.&#x22;,
    required: true,
  },
  productIds: {
    type: &#x22;string[]&#x22;,
    description: &#x22;Product identifiers available on the paywall.&#x22;,
    required: true,
  },
  presentedBy: {
    type: &#x22;string&#x22;,
    description: &#x22;Source that initiated the paywall presentation.&#x22;,
    required: true,
  },
  state: {
    type: &#x22;Record<string, any>&#x22;,
    description: &#x22;Paywall state captured on dismiss.&#x22;,
    required: true,
  },
  customerInfo: {
    type: &#x22;CustomerInfo?&#x22;,
    description: &#x22;Android 2.7.12+ snapshot of the user's subscription and entitlement state. Undefined on iOS.&#x22;,
  },
}"
/>

### Product

<TypeTable
  type="{
  id: {
    type: &#x22;string&#x22;,
    description: &#x22;Product identifier.&#x22;,
    required: true,
  },
  name: {
    type: &#x22;string?&#x22;,
    description: &#x22;Product display name, when available.&#x22;,
  },
  entitlements: {
    type: &#x22;Entitlement[]&#x22;,
    description: &#x22;Entitlements granted by purchasing this product.&#x22;,
    required: true,
  },
  store: {
    type: &#x22;ProductStore?&#x22;,
    description: &#x22;Store that backs this product. Use `\&#x22;CUSTOM\&#x22;` to route purchases to your own purchase logic.&#x22;,
  },
  appStoreProduct: {
    type: &#x22;{ id: string }?&#x22;,
    description: &#x22;App Store product identifier data when `store` is `\&#x22;APP_STORE\&#x22;`.&#x22;,
  },
  stripeProduct: {
    type: &#x22;{ id: string; trialDays?: number }?&#x22;,
    description: &#x22;Stripe product identifier data when `store` is `\&#x22;STRIPE\&#x22;`.&#x22;,
  },
  paddleProduct: {
    type: &#x22;{ id: string }?&#x22;,
    description: &#x22;Paddle product identifier data when `store` is `\&#x22;PADDLE\&#x22;`.&#x22;,
  },
  customProduct: {
    type: &#x22;{ id: string }?&#x22;,
    description: &#x22;Custom product identifier data when `store` is `\&#x22;CUSTOM\&#x22;`.&#x22;,
  },
}"
/>

### CustomerInfo (Android)

<TypeTable
  type="{
  userId: {
    type: &#x22;string&#x22;,
    description: &#x22;User ID at the time the snapshot was taken.&#x22;,
    required: true,
  },
  subscriptions: {
    type: &#x22;SubscriptionTransaction[]&#x22;,
    description: &#x22;Subscription transactions ordered by purchase date.&#x22;,
    required: true,
  },
  nonSubscriptions: {
    type: &#x22;NonSubscriptionTransaction[]&#x22;,
    description: &#x22;Non-subscription transactions ordered by purchase date.&#x22;,
    required: true,
  },
  entitlements: {
    type: &#x22;Entitlement[]&#x22;,
    description: &#x22;Entitlements available to the user.&#x22;,
    required: true,
  },
}"
/>

### SubscriptionTransaction (Android)

<TypeTable
  type="{
  transactionId: {
    type: &#x22;string&#x22;,
    description: &#x22;Unique transaction identifier.&#x22;,
    required: true,
  },
  productId: {
    type: &#x22;string&#x22;,
    description: &#x22;Subscription product identifier.&#x22;,
    required: true,
  },
  purchaseDate: {
    type: &#x22;string&#x22;,
    description: &#x22;ISO-8601 purchase timestamp.&#x22;,
    required: true,
  },
  willRenew: {
    type: &#x22;boolean&#x22;,
    description: &#x22;Whether the subscription is set to renew.&#x22;,
    required: true,
  },
  isRevoked: {
    type: &#x22;boolean&#x22;,
    description: &#x22;Whether the transaction has been revoked.&#x22;,
    required: true,
  },
  isInGracePeriod: {
    type: &#x22;boolean&#x22;,
    description: &#x22;Whether the subscription is in a billing grace period.&#x22;,
    required: true,
  },
  isInBillingRetryPeriod: {
    type: &#x22;boolean&#x22;,
    description: &#x22;Whether the subscription is in a billing retry period.&#x22;,
    required: true,
  },
  isActive: {
    type: &#x22;boolean&#x22;,
    description: &#x22;Whether the subscription is currently active.&#x22;,
    required: true,
  },
  expirationDate: {
    type: &#x22;string | null&#x22;,
    description: &#x22;ISO-8601 expiration timestamp, or null for non-renewing subscriptions.&#x22;,
  },
  store: {
    type: &#x22;string&#x22;,
    description: &#x22;Store the transaction came from, such as `\&#x22;PLAY_STORE\&#x22;`.&#x22;,
    required: true,
  },
  offerType: {
    type: &#x22;\&#x22;trial\&#x22; | \&#x22;code\&#x22; | \&#x22;subscription\&#x22; | \&#x22;promotional\&#x22; | \&#x22;winback\&#x22; | \&#x22;revoked\&#x22;&#x22;,
    description: &#x22;Offer type applied to the subscription, when available.&#x22;,
  },
}"
/>

### NonSubscriptionTransaction (Android)

<TypeTable
  type="{
  transactionId: {
    type: &#x22;string&#x22;,
    description: &#x22;Unique transaction identifier.&#x22;,
    required: true,
  },
  productId: {
    type: &#x22;string&#x22;,
    description: &#x22;Product identifier.&#x22;,
    required: true,
  },
  purchaseDate: {
    type: &#x22;string&#x22;,
    description: &#x22;ISO-8601 purchase timestamp.&#x22;,
    required: true,
  },
  isConsumable: {
    type: &#x22;boolean&#x22;,
    description: &#x22;Whether the purchase is consumable.&#x22;,
    required: true,
  },
  isRevoked: {
    type: &#x22;boolean&#x22;,
    description: &#x22;Whether the transaction has been revoked.&#x22;,
    required: true,
  },
  store: {
    type: &#x22;string&#x22;,
    description: &#x22;Store the transaction came from, such as `\&#x22;PLAY_STORE\&#x22;`.&#x22;,
    required: true,
  },
}"
/>

## Returned Values

This hook does not return any values (`void`). Its purpose is to set up and tear down event listeners.

## Example

```tsx
import { useSuperwallEvents } from "expo-superwall";

function EventLogger() {
  useSuperwallEvents({
    onSuperwallEvent: (eventInfo) => {
      console.log("Superwall Event:", eventInfo.event.event, eventInfo.params);
    },
    onSubscriptionStatusChange: (newStatus) => {
      console.log("Subscription Status Changed:", newStatus.status);
    },
    onPaywallPresent: (info) => {
      console.log("Paywall Presented (via useSuperwallEvents):", info.name);
    },
    onUserAttributesChange: (newAttributes) => {
      console.log("User Attributes Changed:", newAttributes);
      // Sync with analytics or update in-memory state
    },
  });
}
```