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

User object

When a user is signed in, tiun exposes them to your app as a user object. It's the canonical "who is this person and what can they use" record on the client.


Reading the user

Call tiun.getUser() to read the current state. It returns an object shaped like:

{ isAuthenticated, user }

When someone is signed in, user is the user object. When they're not, user is null and isAuthenticated is false.

The same payload is also available on every userChange event, so you rarely call getUser() directly — listening to userChange keeps your UI in sync. For one-off reads, the quick-access properties tiun.user and tiun.isAuthenticated are also available. See SDK properties.


Shape

Field
Type
Description

userId

string

Stable identifier for this user in tiun.

email

string

Email on the account; used for receipts and identification.

productAccess

string[]

Product IDs the user currently has active access to. See Product access.


Typical payloads

Unauthenticated:

{ isAuthenticated: false, user: null }

Authenticated, no purchases:

Authenticated with active subscriptions:


When the user object updates

The user object is populated and refreshed at several points:

  • After a successful checkout (event: 'checkout')

  • After a successful login (event: 'login')

  • After session restore on page load (event: 'init')

  • After logout, where user becomes null (event: 'logout')

  • When entitlements change — for example a subscription expires, removing its product ID from productAccess

Listen to userChange so your UI reflects each of these moments. For UI gating patterns built on top of this state, see Protecting content.

Last updated

Was this helpful?