tiun-sdk
tiun SDK skill
Use this skill whenever the user is integrating, extending, or debugging code that uses @tiun/sdk or @tiun/react-native-sdk. Authoritative upstream docs: https://docs.tiun.io/llms-full.txt.
What tiun is
A commercial backend platform providing authentication, payments, and entitlements through a single JS SDK. The tiun singleton supports three flows; you pick based on the integrator's intent (see "Step 0 — Discovery before code"):
- Subscriptions — persistent user accounts (OTP login), recurring billing, per-product entitlements in
user.productAccess[]. Entry point:tiun.checkout({ productId }). See references/subscriptions.md. - One-time purchases — same accounts and same entry point as subscriptions, but a single fixed fee and permanent entitlement: no interval, no trial, no renewal, no expiry. Entry point:
tiun.checkout({ productId }). See references/one-time.md. - Time-based — per-session anonymous access (no account required), metered by time spent on paid content. Entry point:
tiun.start()+paywallShow/paywallHideevents. See references/time-based.md.
Install: npm install @tiun/sdk. Init: tiun.init({ snippetId, language: 'en' }) on app start (idempotent).
tiun runs live and sandbox as two independent parallel environments. The SDK's sandbox flag selects which one — see references/installation.md.
React Native is a separate SDK. @tiun/react-native-sdk uses <TiunProvider> + useTiun() / useTiunEvent(), selects the environment with host (no sandbox flag), needs a returnUrl deep link, and covers subscriptions and one-time purchases only. Everything about it is in references/react-native.md. The tiun.* code, Minimal working example, and per-framework wiring below are web-only — never generate them in a React Native app.