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, charged as a single fixed fee: no interval, no trial, no renewal, no cancellation. Access is permanent by default. Limited access gives the purchase an end date; Repeat purchases lets the same customer buy again, once per
referenceId. Entry point:tiun.checkout({ productId }), plusreferenceIdwhen the product is repeatable. 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' }) once, on app start, ideally in the app root (idempotent).
Products and access at runtime (@tiun/sdk 0.12.0+, @tiun/react-native-sdk 0.5.0+ on useTiun()): tiun.listProducts(), tiun.getProduct(productId) (localized pricing), tiun.listProductAccess(), and tiun.checkProductAccess(productId, { referenceId }). They work without a backend, including for repeatable products. See references/api-reference.md.
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.