# useSuperwall

## [Purpose](/content/docs/expo/sdk-reference/hooks/useSuperwall#purpose/index.html)

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)](/content/docs/expo/sdk-reference/hooks/useSuperwall#returned-values-store-state-and-actions/index.html)

The hook returns an object representing the Superwall store. If a `selector` function is provided, it returns the selected slice of the store.

### [State](/content/docs/expo/sdk-reference/hooks/useSuperwall#state/index.html)

| Prop                      | Type                                       |
|---------------------------|--------------------------------------------|
| `isConfigured?`          | boolean                                    |
| `isLoading?`             | boolean                                    |
| `listenersInitialized?`   | boolean                                    |
| `configurationError?`    | string \| null                            |
| `user?`                  | UserAttributes \| null                    |
| `subscriptionStatus?`     | SubscriptionStatus                         |

### [Actions (Functions)](/content/docs/expo/sdk-reference/hooks/useSuperwall#actions-functions/index.html)

| Prop                            | Type                                                                                 |
|---------------------------------|--------------------------------------------------------------------------------------|
| `configure?`                   | (apiKey: string, options?: PartialSuperwallOptions) => Promise<void>               |
| `identify?`                    | (userId: string, options?: IdentifyOptions) => Promise<void>                       |
| `reset?`                       | () => Promise<void>                                                                  |
| `registerPlacement?`           | (placement: string, params?: Record<string, any>, handlerId?: string \| null) => Promise<void> |
| `getPresentationResult?`       | (placement: string, params?: Record<string, any>) => Promise<PresentationResult>   |
| `restorePurchases?`           | () => Promise<RestorationResultResponse>                                            |
| `dismiss?`                    | () => Promise<void>                                                                  |
| `preloadAllPaywalls?`         | () => Promise<void>                                                                  |
| `preloadPaywalls?`            | (placements: string[]) => Promise<void>                                             |
| `setUserAttributes?`          | (attrs: Record<string, any \| null>) => Promise<void>                              |
| `getUserAttributes?`          | () => Promise<Record<string, any>>                                                 |
| `setLogLevel?`                | (level: string) => Promise<void>                                                   |
| `setIntegrationAttributes?`    | (attributes: IntegrationAttributes) => Promise<void>                                 |
| `getIntegrationAttributes?`    | () => Promise<Record<string, string>>                                              |
| `setSubscriptionStatus?`       | (status: SubscriptionStatus) => Promise<void>                                       |
| `getDeviceAttributes?`        | () => Promise<Record<string, any>>                                                 |
| `getEntitlements?`            | () => Promise<EntitlementsInfo>                                                    |

### [Selector (Optional Parameter)](/content/docs/expo/sdk-reference/hooks/useSuperwall#selector-optional-parameter/index.html)

| Prop                      | Type                                  |
|---------------------------|---------------------------------------|
| `selector?`              | (state: SuperwallStore) => T         |

### [UserAttributes](/content/docs/expo/sdk-reference/hooks/useSuperwall#userattributes/index.html)

| Prop                      | Type                         |
|---------------------------|------------------------------|
| `aliasId?`               | string                       |
| `appUserId?`            | string                       |
| `applicationInstalledAt?` | string                      |
| `seed?`                  | number                       |
| `[key: string]?`        | any \| null                 |

### [SubscriptionStatus](/content/docs/expo/sdk-reference/hooks/useSuperwall#subscriptionstatus/index.html)

| Prop                      | Type                                  |
|---------------------------|---------------------------------------|
| `status`                  | "UNKNOWN" \| "INACTIVE" \| "ACTIVE" |
| `entitlements?`          | Entitlement[]?                        |

### [EntitlementsInfo](/content/docs/expo/sdk-reference/hooks/useSuperwall#entitlementsinfo/index.html)

| Prop                      | Type                    |
|---------------------------|-------------------------|
| `all?`                   | Entitlement[]?          |
| `active`                 | Entitlement[]           |
| `inactive`               | Entitlement[]           |

### [RestorationResultResponse](/content/docs/expo/sdk-reference/hooks/useSuperwall#restorationresultresponse/index.html)

| Prop                      | Type                            |
|---------------------------|---------------------------------|
| `result`                  | "restored" \| "failed"      |
| `errorMessage?`          | string \| null                 |

## [Example](/content/docs/expo/sdk-reference/hooks/useSuperwall#example/index.html)

(Direct Usage - Advanced)

```javascript
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](/content/docs/expo/sdk-reference/hooks/useSuperwall#example-configure-with-android-identifiers/index.html)

```javascript
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,
  })
}
```
