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
isAuthenticatedisfalse, show the public experience or your sign-in / pricing UI.If
isAuthenticatedistrue, check whether the relevant product ID is inproductAccess. 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 purchases — subscription or one-time
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 every event name and its full payload, see SDK events.
Last updated
Was this helpful?

