# 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

# PaywallView

Embed a placement's paywall inside your own Flutter widget tree with the PaywallView widget, instead of presenting it over the app.

## Purpose

`PaywallView` is a widget that shows the paywall for a placement inside your own layout, such as a section of a screen, a tab or an onboarding page. Use it when the paywall should be part of a screen instead of being presented over the app by [`registerPlacement()`](/docs/flutter/sdk-reference/register).

The widget retrieves the paywall when it's first built. While it loads, it shows `loadingBuilder`. If the user shouldn't see a paywall, it shows `skippedBuilder`, and if the paywall couldn't be retrieved, it shows `errorBuilder`.

> **Info:** `PaywallView` is available in Flutter SDK 2.9.0 and later, on Android and iOS. Call [`configure()`](/docs/flutter/sdk-reference/configure) before you build one.

## Signature

```dart
class PaywallView extends StatefulWidget {
  const PaywallView({
    Key? key,
    required String placement,
    Map<String, Object>? params,
    void Function(PaywallInfo paywallInfo)? onPresent,
    void Function(PaywallInfo paywallInfo, PaywallResult result, bool shouldDismiss)? onFinished,
    void Function(PaywallSkippedReason reason)? onSkip,
    void Function(String error)? onError,
    WidgetBuilder? loadingBuilder,
    Widget Function(BuildContext context, PaywallSkippedReason reason)? skippedBuilder,
    Widget Function(BuildContext context, String error)? errorBuilder,
    void Function(PaywallLoadingState state)? onLoadingStateChanged, // iOS only
    Future<CustomCallbackResult> Function(CustomCallback callback)? onCustomCallback, // iOS only
    Set<Factory<OneSequenceGestureRecognizer>>? gestureRecognizers,
  });
}
```

## Parameters

<TypeTable
  type="{
  placement: {
    type: &#x22;String&#x22;,
    description: &#x22;The name of the placement, as defined on the Superwall dashboard, whose paywall is shown.&#x22;,
    required: true,
  },
  params: {
    type: &#x22;Map<String, Object>?&#x22;,
    description: &#x22;Optional parameters to send with the placement. You can reference them in your campaign's audience filters.&#x22;,
    default: &#x22;null&#x22;,
  },
  onPresent: {
    type: &#x22;void Function(PaywallInfo paywallInfo)?&#x22;,
    description: &#x22;Called when the paywall was retrieved and added to the view.&#x22;,
    default: &#x22;null&#x22;,
  },
  onFinished: {
    type: &#x22;void Function(PaywallInfo paywallInfo, PaywallResult result, bool shouldDismiss)?&#x22;,
    description: &#x22;Called when the user purchased, restored or declined the paywall. `result` is a `PurchasedPaywallResult`, `RestoredPaywallResult` or `DeclinedPaywallResult`. When `shouldDismiss` is `true`, the paywall has left the view and your app should remove the `PaywallView`. When it's `false`, the paywall stays on screen, for example when `PaywallOptions.automaticallyDismiss` is off.&#x22;,
    default: &#x22;null&#x22;,
  },
  onSkip: {
    type: &#x22;void Function(PaywallSkippedReason reason)?&#x22;,
    description: &#x22;Called when no paywall is shown, for example because the user is in a holdout or didn't match an audience. `skippedBuilder` is shown instead.&#x22;,
    default: &#x22;null&#x22;,
  },
  onError: {
    type: &#x22;void Function(String error)?&#x22;,
    description: &#x22;Called when the paywall couldn't be retrieved. `errorBuilder` is shown instead.&#x22;,
    default: &#x22;null&#x22;,
  },
  loadingBuilder: {
    type: &#x22;WidgetBuilder?&#x22;,
    description: &#x22;Builds the widget shown over the view while the paywall loads. `null` shows nothing over the view.&#x22;,
    default: &#x22;null&#x22;,
  },
  skippedBuilder: {
    type: &#x22;Widget Function(BuildContext context, PaywallSkippedReason reason)?&#x22;,
    description: &#x22;Builds the widget shown when no paywall is shown. `null` renders nothing.&#x22;,
    default: &#x22;null&#x22;,
  },
  errorBuilder: {
    type: &#x22;Widget Function(BuildContext context, String error)?&#x22;,
    description: &#x22;Builds the widget shown when the paywall couldn't be retrieved. `null` renders nothing.&#x22;,
    default: &#x22;null&#x22;,
  },
  onLoadingStateChanged: {
    type: &#x22;void Function(PaywallLoadingState state)?&#x22;,
    description: &#x22;Called when the paywall's loading state changes. iOS only. It's never called on Android.&#x22;,
    default: &#x22;null&#x22;,
  },
  onCustomCallback: {
    type: &#x22;Future<CustomCallbackResult> Function(CustomCallback callback)?&#x22;,
    description: &#x22;Called when the paywall requests a custom callback. Works like `PaywallPresentationHandler.onCustomCallback`. Without it, custom callbacks are answered with a failure. iOS only. It's never called on Android.&#x22;,
    typeDescriptionLink: &#x22;/flutter/sdk-reference/PaywallPresentationHandler&#x22;,
    default: &#x22;null&#x22;,
  },
  gestureRecognizers: {
    type: &#x22;Set<Factory<OneSequenceGestureRecognizer>>?&#x22;,
    description: &#x22;Which gestures the paywall takes from the widgets around it, such as a scroll view it's placed in. `null` claims every gesture that starts on the paywall, with an `EagerGestureRecognizer`. Pass your own set, or an empty one, to change that.&#x22;,
    default: &#x22;null&#x22;,
  },
}"
/>

### PaywallLoadingState

`onLoadingStateChanged` receives one of these values:

<TypeTable
  type="{
  unknown: {
    type: &#x22;PaywallLoadingState&#x22;,
    description: &#x22;The loading state isn't known yet.&#x22;,
  },
  loadingPurchase: {
    type: &#x22;PaywallLoadingState&#x22;,
    description: &#x22;The paywall is waiting on a purchase or a restore.&#x22;,
  },
  loadingUrl: {
    type: &#x22;PaywallLoadingState&#x22;,
    description: &#x22;The paywall is loading its web page.&#x22;,
  },
  manualLoading: {
    type: &#x22;PaywallLoadingState&#x22;,
    description: &#x22;The paywall was told to show its loading indicator.&#x22;,
  },
  ready: {
    type: &#x22;PaywallLoadingState&#x22;,
    description: &#x22;The paywall is ready for the user to interact with.&#x22;,
  },
}"
/>

## Add a paywall to a screen

1. Call [`configure()`](/docs/flutter/sdk-reference/configure) when your app starts, before any `PaywallView` is built.
2. Put a `PaywallView` in a parent with a bounded size, such as a `SizedBox` or an `Expanded`. It fills the space its parent gives it.
3. Set `placement` to a placement that has a campaign on the Superwall dashboard.
4. In `onFinished`, check the `result` and unlock the feature if the user purchased or restored.
5. When `onFinished` reports `shouldDismiss` as `true`, remove the `PaywallView` from your widget tree.

```dart
import 'package:flutter/material.dart';
import 'package:superwallkit_flutter/superwallkit_flutter.dart';

class UpgradeCard extends StatefulWidget {
  const UpgradeCard({super.key});

  @override
  State<UpgradeCard> createState() => _UpgradeCardState();
}

class _UpgradeCardState extends State<UpgradeCard> {
  bool _showPaywall = true;
  bool _isPro = false;

  @override
  Widget build(BuildContext context) {
    if (_isPro) {
      return const Text('Thanks for upgrading!');
    }
    if (!_showPaywall) {
      return const SizedBox.shrink();
    }

    return SizedBox(
      height: 500,
      child: PaywallView(
        placement: 'upgrade_card',
        params: {'source': 'home_screen'},
        loadingBuilder: (context) =>
            const Center(child: CircularProgressIndicator()),
        skippedBuilder: (context, reason) => const SizedBox.shrink(),
        errorBuilder: (context, error) =>
            const Center(child: Text('This offer is unavailable.')),
        onPresent: (paywallInfo) {
          debugPrint('Showing ${paywallInfo.name}');
        },
        onFinished: (paywallInfo, result, shouldDismiss) {
          setState(() {
            switch (result) {
              case PurchasedPaywallResult():
              case RestoredPaywallResult():
                _isPro = true;
              case DeclinedPaywallResult():
                break;
            }
            if (shouldDismiss) {
              _showPaywall = false;
            }
          });
        },
      ),
    );
  }
}
```

### Inside a scroll view

By default, the paywall claims every gesture that starts on it, so the paywall scrolls instead of its parent. To let a parent `ListView` scroll when the user drags across the paywall, pass an empty set:

```dart
SizedBox(
  height: 400,
  child: PaywallView(
    placement: 'inline_offer',
    gestureRecognizers: const {},
  ),
)
```

## Limitations

* `PaywallView` works on Android and iOS only. On other platforms it shows `errorBuilder` with the error `PaywallView is only available on Android and iOS.`
* There's no `feature` callback like the one on `registerPlacement()`. The result arrives in `onFinished`, where you decide whether to unlock the feature.
* Don't show the same paywall in two `PaywallView`s at once. The native SDKs share one paywall instance per paywall, so give each mounted view a placement that leads to a different paywall.
* Call `Superwall.configure()` first. Otherwise the view shows `errorBuilder` with the error `Superwall must be configured before a PaywallView is shown.`
* Each view shows one placement with one set of `params`. When either changes, the view is recreated and the paywall is retrieved again.
* After `onFinished` reports `shouldDismiss` as `true`, the view renders nothing.
* `onLoadingStateChanged` and `onCustomCallback` are iOS only.

## Related

* [Retrieving and Presenting a Paywall Yourself](/docs/flutter/guides/advanced/presenting-paywalls)
* [`registerPlacement()`](/docs/flutter/sdk-reference/register) presents a placement's paywall over the app.
* [`PaywallPresentationHandler`](/docs/flutter/sdk-reference/PaywallPresentationHandler) has the same callbacks for a presented paywall.
* [`PaywallOptions`](/docs/flutter/sdk-reference/PaywallOptions) sets `automaticallyDismiss`, which controls `shouldDismiss` after a purchase or restore.