For the complete documentation index, see llms.txt. This page is also available as Markdown.

Examples

Common tiun patterns in a React Native app. Each section is standalone — use what applies to your integration.

These assume the SDK and its native dependencies are installed and your return deep link is registered. See Installation if not.


Set up the provider

Keep the config and your product IDs in one module so screens, gating logic, and analytics all reference the same values.

// tiun.ts
import type { TiunConfig } from '@tiun/react-native-sdk';

export const TIUN_CONFIG: TiunConfig = {
  snippetId: 'YOUR_SNIPPET_ID',
  returnUrl: 'myapp://tiun/return',
  language: 'en', // 'en' | 'de' | 'fr'
};

export const TIUN_PRODUCTS = {
  light: 'p-live-light',
  pro: 'p-live-pro',
} as const;

Wrap the app root in the provider:


Checkout

Call checkout() with the product ID from your dashboard. tiun opens the overlay and handles email, payment, and access in one flow.


Track the user

useTiun() already re-renders your component when the user changes, so for most screens reading user directly is enough:

Use useTiunEvent('userChange') when you need to react to the change — refetching data, resetting a screen, or mirroring the user into your own store:

userChange also fires once when the stored session is restored at launch, so this covers the initial state too.


Gate content

Derive what the user can see from productAccess. Deriving a single "current tier" keeps the check in one place instead of scattering includes() calls through your screens.

Then gate on it:


Login and logout

Returning subscribers sign in without going through checkout again. Their productAccess comes back with the session.


Verify on your server

Client-side gating controls what the app renders. If your backend serves the premium payload itself, verify the user there before responding.

The backend half is the same as for the web SDK — see verify authentication server-side and verify subscriptions server-side.


Full example

A tiered app in one file: entitlements drive the current tier, the pricing screen opens checkout, and the tab bar handles auth.


For the full API, see Hooks and events. For an end-to-end walkthrough from dashboard to production, see monetize in React Native in Guides.

Last updated

Was this helpful?