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

Protecting content

Content gating is driven by two pieces of state on the user object — isAuthenticated and productAccess — kept in sync by the userChange event.


Reading access

Combine isAuthenticated with productAccess to decide what to show:

  • If isAuthenticated is false, show the public experience or your sign-in / pricing UI.

  • If isAuthenticated is true, check whether the relevant product ID is in productAccess. If yes, unlock the gated experience; if not, offer an upgrade.

The shape of the user object is documented in User object. The semantics of the productAccess array — what it contains, when it changes — are documented in Product access.


Reacting to changes

Subscribe to userChange and update your UI from the event payload. It fires on session init, after login, after checkout, after logout, and any time entitlements change — so your gates stay aligned without polling.

Trigger

Method

Resulting userChange event

User subscribes

tiun.checkout({ productId })

event: 'checkout', user authenticated, productAccess reflects the new product

Returning visitor

Automatic on page load

event: 'init', session restored

Existing user signs in

tiun.login()

event: 'login', user authenticated

User signs out

tiun.logout()

event: 'logout', user is null


Example

For all event names and full payloads, see SDK events.

Last updated

Was this helpful?