Superwall

configure()

A static function that configures a shared instance of Superwall for use throughout your app.

Deprecated SDK

We strongly recommend migrating to the new Superwall Expo SDK, see our migration guide for details.

This is a static method called on the Superwall class itself, not on the shared instance.

Purpose

Configures the shared instance of Superwall with your API key and optional configurations, making it ready for use throughout your app.

Signature

static async configure({
  apiKey,
  options,
  purchaseController,
  completion,
}: {
  apiKey: string
  options?: SuperwallOptions
  purchaseController?: PurchaseController
  completion?: () => void
}): Promise<Superwall>

Parameters

NameTypeDescription
apiKeystringYour Public API Key from the Superwall dashboard settings.
optionsSuperwallOptions?Optional configuration object for customizing paywall appearance and behavior. See SuperwallOptions for details. Defaults to undefined.
purchaseControllerPurchaseController?Optional object for handling all subscription-related logic yourself. If omitted, Superwall handles subscription logic. Defaults to undefined.
completion(() => void)?Optional completion handler called when Superwall finishes configuring. Defaults to undefined.

Returns / State

Returns a Promise that resolves to the configured Superwall instance. The instance is also accessible via Superwall.shared.

Usage

Basic configuration:

import Superwall from "@superwall/react-native-superwall"

await Superwall.configure({
  apiKey: "pk_your_api_key"
})

With custom options:

import Superwall, { SuperwallOptions } from "@superwall/react-native-superwall"

const options = new SuperwallOptions({
  paywalls: {
    shouldShowPurchaseFailureAlert: false
  }
})

await Superwall.configure({
  apiKey: "pk_your_api_key",
  options: options,
  completion: () => {
    console.log("Superwall configured successfully")
  }
})

With custom purchase controller:

import Superwall, { PurchaseController } from "@superwall/react-native-superwall"

class MyPurchaseController extends PurchaseController {
  async purchaseFromAppStore(productId: string): Promise<PurchaseResult> {
    // Your purchase logic
  }
  
  async purchaseFromGooglePlay(productId: string, basePlanId?: string, offerId?: string): Promise<PurchaseResult> {
    // Your purchase logic
  }
  
  async restorePurchases(): Promise<RestorationResult> {
    // Your restore logic
  }
}

await Superwall.configure({
  apiKey: "pk_your_api_key",
  purchaseController: new MyPurchaseController()
})

How is this guide?

Edit on GitHub