Hooks
useSuperwall
Purpose
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.
Returned Values (Store State and Actions)
The hook returns an object representing the Superwall store. If a selector function is provided, it returns the selected slice of the store.
State
Prop
Type
Actions (Functions)
Prop
Type
Selector (Optional Parameter)
Prop
Type
UserAttributes
Prop
Type
SubscriptionStatus
Prop
Type
Example
(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} />;
}Example: Configure with Android identifiers
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,
})
}How is this guide?
Edit on GitHub