<SuperwallProvider />.
Function Signature
Parameters
An object where keys are event names and values are the corresponding callback functions.
Paywall Lifecycle Callbacks
Called when a paywall is presented.
Called when a paywall is dismissed.
result.typecan be: “purchased”, “declined”, or “restored”
Called when a paywall is skipped.
reason.typecan be: “Holdout”, “NoAudienceMatch”, or “PlacementNotFound”
Called when an error occurs during paywall presentation or other SDK operations.
Called just before a paywall is presented.
Called after a paywall has been presented.
Called just before a paywall is dismissed.
Called after a paywall has been dismissed.
Subscription & User Callbacks
Called when the user’s subscription status changes.
Purchase Callbacks
Called when a purchase is initiated.
- iOS: includes
productIdandplatform - Android: includes
productId,platform,basePlanId, andofferId
Called when a purchase restoration is initiated.
Link & URL Callbacks
Called when the paywall attempts to open a URL.
Called when the paywall attempts to open a deep link.
Called before the SDK attempts to redeem a promotional link.
Called after the SDK has attempted to redeem a promotional link.
result.statuscan be: “SUCCESS”, “ERROR”, “CODE_EXPIRED”, “INVALID_CODE”, or “EXPIRED_SUBSCRIPTION”
General Event Callbacks
Called for all Superwall internal events. This is a general-purpose event handler that receives all SDK events.
- Use this for comprehensive event logging or analytics
Called when a custom action is triggered from a paywall (e.g., via
superwall.triggerCustomPaywallAction('myAction')).callbacks.onCustomCallback
(callback: CustomCallback) => Promise<CustomCallbackResult> | CustomCallbackResult
Called when a custom callback is invoked from a paywall. Custom callbacks allow paywalls to communicate with the app to perform operations like validation, data fetching, etc.Parameters:
callback.name: string- The callback namecallback.variables?: Record<string, any>- Optional variables from paywall
status: "success" | "failure"- Whether the callback succeededdata?: Record<string, any>- Optional data to return to paywall
Logging Callbacks
Called for logging messages from the SDK.LogParams:
level: LogLevel- “debug”, “info”, “warn”, “error”scope: LogScope- The scope/category of the logmessage: string | null- The log messageinfo: Record<string, any> | null- Additional infoerror: string | null- Error message if applicable
Internal Parameters
An optional identifier used to scope certain events (like
onPaywallPresent, onPaywallDismiss, onPaywallSkip) to a specific usePlacement hook instance. This is primarily used internally by the usePlacement hook.Android only. Called when the back button is pressed while a paywall is displayed. Only triggered when
rerouteBackButton is enabled in the paywall settings.Returns:trueto consume the back press and prevent default dismiss behaviorfalseto allow normal dismiss
Return Value
This hook does not return any values. Its purpose is to set up and tear down event listeners.Usage Examples
Basic event logging
Comprehensive event tracking
Error tracking
Custom logging
Purchase flow tracking
Deep link handling
Promotional code redemption
Custom callback implementation
Lifecycle event tracking
Best Practices
- Use for global event tracking: This hook is ideal for app-wide event logging, analytics, and monitoring
- Keep callbacks lightweight: Event callbacks should execute quickly to avoid blocking the UI
- Use
usePlacementfor placement-specific events: For paywall-specific logic, preferusePlacementcallbacks over this hook - Avoid state updates in all event callbacks: Be selective about which events trigger state updates to prevent excessive re-renders
- Implement error handling: Always handle errors in async callbacks (like
onCustomCallback)
Related Hooks
- usePlacement - Higher-level hook for paywall presentation with scoped events
- useUser - User management hook
- useSuperwall - Core SDK access hook
Related Types
SuperwallEventCallbacks(useSuperwallEvents.ts:23)PaywallInfo(SuperwallExpoModule.types.ts:392)PaywallResult(SuperwallExpoModule.types.ts:177)PaywallSkippedReason(SuperwallExpoModule.types.ts:148)SubscriptionStatus(SuperwallExpoModule.types.ts:205)SuperwallEventInfo(SuperwallExpoModule.types.ts - see SuperwallEvent union type)CustomCallback(SuperwallExpoModule.types.ts:499)CustomCallbackResult(SuperwallExpoModule.types.ts:517)RedemptionResult(SuperwallExpoModule.types.ts:769)LogLevelandLogScopetypes in SuperwallExpoModule.types.ts