# React Native

Install the independent npm package for Customer identity, entitlement reads and backend-mediated usage reporting.

[Web version](https://www.longplayai.com/docs/sdk/react-native)

<a id="install"></a>

## Install the React Native SDK

Install the independent npm package from latest. Requires React Native 0.79+, Metro 0.82+ and package exports support. --save-exact writes the resolved version to package.json; commit the lockfile and use npm ci afterward.

**terminal**

```bash
npm install --save-exact @tinkerlandai/longplay-react-native@latest
npm ls @tinkerlandai/longplay-react-native --depth=0
```

Import `createLongplayReactNative` from `@tinkerlandai/longplay-react-native`. The package includes ESM, CommonJS and TypeScript declarations, and its data client uses Fetch and AbortController with no native linking; optional native integration is added through autolinking.

The independent package and the `@tinkerlandai/longplay-sdk/react-native` subpath share the same core implementation; choose one entry per app. Both cover Customer identity, holdings, entitlement checks, commerce commands, Offering/Paywall/content resolution, experiments and events. The independent package's optional native integration adds Funnel/Paywall/content presentation and Apple/Google purchase, restore and subscription-management bridges. Trusted usage writes still go through the backend.

<a id="identity"></a>

## Identity and usage after installation

- The stable SDK uses protocol 0.10 with https://api.longplayai.com and a Sandbox App and credentials issued by that production deployment. Sandbox still contains production data.
- Your backend issues the complete Customer session for its authenticated user: accessToken (Customer Token), refreshToken, customerId, sessionId, expiresAt and refreshExpiresAt. Use identify(session:) in Swift and identify(session) in Kotlin or React Native; call reset at logout. Customer creation, updates and credential issuance belong on the backend.
- The SDK refreshes directly with the Longplay API before Access expires, sharing one refresh across concurrent requests. Successful rotation preserves identity and business state. A lost reply retains the Refresh Token for the next attempt; a definitive authentication refusal or expired Refresh Token requires a new login. Refresh never automatically replays a business write.
- Clients use only the Access Token to read the current Customer's holdings and entitlements; a Refresh Token cannot access business endpoints. Passing only an Access Token leaves renewal to the host. Never ship a Server Key in the app.
- Relay usage through your own authenticated backend. The backend selects the Customer from the app session and calls a server SDK with its Server Key; retries retain the original idempotencyKey.

- [Customers and sessions](https://www.longplayai.com/docs/guides/customers.md)
- [Entitlements and usage](https://www.longplayai.com/docs/guides/entitlements.md)
