useSuperwall
The useSuperwall hook is the core hook that provides access to the Superwall store and underlying SDK functionality. It's generally used internally by other more specific hooks like useUser and usePlacement, but can be used directly for advanced scenarios. It ensures that native event listeners are set up on first use.
The hook returns an object representing the Superwall store. If a selector function is provided, it returns the selected slice of the store.
| Prop |
Type |
isConfigured? |
boolean |
isLoading? |
boolean |
listenersInitialized? |
boolean |
configurationError? |
string | null |
user? |
UserAttributes | null |
subscriptionStatus? |
SubscriptionStatus |
| Prop |
Type |
configure? |
(apiKey: string, options?: PartialSuperwallOptions) => Promise |
identify? |
(userId: string, options?: IdentifyOptions) => Promise |
reset? |
() => Promise |
registerPlacement? |
(placement: string, params?: Record<string, any>, handlerId?: string | null) => Promise |
getPresentationResult? |
(placement: string, params?: Record<string, any>) => Promise |
restorePurchases? |
() => Promise |
dismiss? |
() => Promise |
preloadAllPaywalls? |
() => Promise |
preloadPaywalls? |
(placements: string[]) => Promise |
setUserAttributes? |
(attrs: Record<string, any | null>) => Promise |
getUserAttributes? |
() => Promise<Record<string, any>> |
setLogLevel? |
(level: string) => Promise |
setIntegrationAttributes? |
(attributes: IntegrationAttributes) => Promise |
getIntegrationAttributes? |
() => Promise<Record<string, string>> |
setSubscriptionStatus? |
(status: SubscriptionStatus) => Promise |
getDeviceAttributes? |
() => Promise<Record<string, any>> |
getEntitlements? |
() => Promise |
| Prop |
Type |
selector? |
(state: SuperwallStore) => T |
| Prop |
Type |
aliasId? |
string |
appUserId? |
string |
applicationInstalledAt? |
string |
seed? |
number |
[key: string]? |
any | null |
| Prop |
Type |
status |
"UNKNOWN" | "INACTIVE" | "ACTIVE" |
entitlements? |
Entitlement[]? |
| Prop |
Type |
all? |
Entitlement[]? |
active |
Entitlement[] |
inactive |
Entitlement[] |
| Prop |
Type |
result |
"restored" | "failed" |
errorMessage? |
string | null |
(Direct Usage - Advanced)
import { useSuperwall } from 'expo-superwall';
function MyAdvancedComponent() {
const { isConfigured, configure, setUserAttributes } = useSuperwall();
if (!isConfigured) {
return <Text>SDK not configured yet.</Text>;
}
const handleSetCustomAttribute = () => {
setUserAttributes({ myCustomFlag: true });
};
return <Button title="Set Custom Flag" onPress={handleSetCustomAttribute} />;
}
import { Platform } from "react-native"
import Superwall from "expo-superwall/compat"
async function configureSuperwall() {
await Superwall.configure({
apiKey: Platform.OS === "ios" ? IOS_KEY : ANDROID_KEY,
options: Platform.OS === "android"
? { passIdentifiersToPlayStore: true }
: undefined,
})
}