identify, reset, registerPlacement).
It must be used within a component that is a descendant of <SuperwallProvider />.
Function Signature
Parameters
An optional function to select a specific slice of the store’s state. This is useful for performance optimization, as components will only re-render if the selected part of the state changes. Uses shallow equality checking via
zustand/shallow. If omitted, the entire store is returned.Return Value
The selected slice of the Superwall store state, or the entire store if no selector is provided. The store includes both state and actions.Store State
Indicates whether the Superwall SDK has been successfully configured.
Indicates whether the SDK is currently performing a loading operation (e.g., configuring, fetching data).
Indicates whether the native event listeners have been initialized.
Contains error message if SDK configuration failed,
null otherwise. When this is set, the SDK is not configured and app should show error UI.The current user’s attributes.
null if no user is identified or after reset is called. undefined initially before any user data is fetched or set.UserAttributes interface:aliasId: string- The user’s alias ID, if setappUserId: string- The user’s application-specific user IDapplicationInstalledAt: string- ISO 8601 date string of when the app was installedseed: number- Seed value for consistent variant assignments[key: string]: any- Custom attributes
The current subscription status of the user. Can be
UNKNOWN, INACTIVE, or ACTIVE with entitlements.Store Actions
Identifies the current user with a unique ID.Parameters:
userId: string- The unique identifier for the useroptions?: IdentifyOptions- Optional parameters:restorePaywallAssignments?: boolean- If true, restores paywall assignments from previous session (defaults to false)
registerPlacement
(placement: string, params?: Record<string, any>, handlerId?: string | null) => Promise<void>
Registers a placement to potentially show a paywall. The decision to show a paywall is determined by campaign rules and user assignments on the Superwall dashboard.Parameters:
placement: string- The ID of the placement to registerparams?: Record<string, any>- Optional parameters to pass with the placementhandlerId?: string | null- Internal identifier used to associate event handlers (defaults to “default”)
Retrieves the presentation result for a given placement without actually registering it.Parameters:
placement: string- The ID of the placementparams?: Record<string, any>- Optional parameters for the placement
Dismisses any currently presented Superwall paywall.
Preloads all paywalls configured in your Superwall dashboard.
Preloads specific paywalls.Parameters:
placements: string[]- Array of placement IDs for which to preload paywalls
Sets custom attributes for the current user.Parameters:
attrs: Record<string, any | null>- Object containing the attributes to set
Retrieves the current user’s attributes from the SDK.
Sets the logging level for the Superwall SDK.Parameters:
level: string- The desired log level: “debug”, “info”, “warn”, “error”, or “none”
Sets attributes for third-party integrations (e.g., Adjust, Amplitude, AppsFlyer).Parameters:
attributes: IntegrationAttributes- Object mapping integration attribute keys to their IDs
Gets the currently set integration attributes.
Manually sets the subscription status of the user.Parameters:
status: SubscriptionStatus- The subscription status to set
Retrieves device-specific attributes.
Retrieves the user’s entitlements from Superwall’s servers, including both active and inactive entitlements.
Zustand Store Structure
TheuseSuperwall hook is built on top of Zustand, a lightweight state management library. The store structure is defined in the SuperwallStore interface:
- State: Reactive properties that trigger component re-renders when they change
- Actions: Functions that modify state or interact with the native SDK
- Selectors: Optional functions to optimize performance by selecting specific slices of state
zustand/shallow) when a selector is provided, preventing unnecessary re-renders when non-selected state changes.
Usage Examples
Get the entire store
Select specific state properties (optimized)
Access configuration state
Preload paywalls
Manage user attributes
Related Hooks
- useUser - Simplified hook for user management
- usePlacement - Hook for paywall presentation
- useSuperwallEvents - Hook for subscribing to SDK events
Related Types
UserAttributes(useSuperwall.ts:19)IdentifyOptions(useSuperwall.ts:37)SuperwallStore(useSuperwall.ts:51)SubscriptionStatus(SuperwallExpoModule.types.ts:205)IntegrationAttributes(SuperwallExpoModule.types.ts:121)EntitlementsInfo(SuperwallExpoModule.types.ts:130)