Hooks
useSuperwallEvents
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.
callbacks?SuperwallEventCallbacks?
onPaywallPresent?(paywallInfo: PaywallInfo) => void
onPaywallDismiss?(paywallInfo: PaywallInfo, result: PaywallResult) => void
onPaywallSkip?(reason: PaywallSkippedReason) => void
onPaywallError?(error: string) => void
onSubscriptionStatusChange?(status: SubscriptionStatus) => void
onUserAttributesChange?(newAttributes: Record<string, any | null>) => void
onSuperwallEvent?(eventInfo: SuperwallEventInfo) => void
onCustomPaywallAction?(name: string) => void
willDismissPaywall?(paywallInfo: PaywallInfo) => void
willPresentPaywall?(paywallInfo: PaywallInfo) => void
didDismissPaywall?(paywallInfo: PaywallInfo) => void
didPresentPaywall?(paywallInfo: PaywallInfo) => void
onPaywallWillOpenURL?(url: string) => void
onPaywallWillOpenDeepLink?(url: string) => void
onLog?(params: { level: LogLevel; scope: LogScope; message: string | null; info: Record<string, any> | null; error: string | null }) => void
willRedeemLink?() => void
didRedeemLink?(result: RedemptionResult) => void
onPurchase?(params: OnPurchaseParams) => void
onPurchaseRestore?() => void
onBackPressed?(paywallInfo: PaywallInfo) => boolean
onCustomCallback?(callback: CustomCallback) => Promise<CustomCallbackResult> | CustomCallbackResult
paramsRecord<string, any>
previousPageNodeId?string?
previousFlowPosition?number?
navigationType"entry" | "forward" | "back" | "auto_transition" | string
timeOnPreviousPageMs?number?
customerInfo?CustomerInfo?
entitlementsEntitlement[]
appStoreProduct?{ id: string }?
stripeProduct?{ id: string; trialDays?: number }?
paddleProduct?{ id: string }?
customProduct?{ id: string }?
subscriptionsSubscriptionTransaction[]
nonSubscriptionsNonSubscriptionTransaction[]
entitlementsEntitlement[]
isInBillingRetryPeriodboolean
expirationDate?string | null
offerType?"trial" | "code" | "subscription" | "promotional" | "winback" | "revoked"
This hook does not return any values (void). Its purpose is to set up and tear down event listeners.
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
},
});
} How is this guide?
Good Bad