Access State

The tiun SDK exposes who is signed in and what they can access. You read that state through a small API and keep your UI in sync by listening for updates.

getUser() and the user object

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

{ isAuthenticated, user }

When someone is signed in, user is an object with userId, email, and productAccess. When they are not signed in, user is null.

Quick-read properties

tiun.isAuthenticated and tiun.user give you a quick read of the current state. Use userChange to keep your UI in sync; use these properties when you need a one-off check of what tiun knows right now.

For more on SDK properties, see SDK propertiesarrow-up-right.

Typical shapes

1. Unauthenticated

{ isAuthenticated: false, user: null }

2. Authenticated, no purchases yet

{
  isAuthenticated: true,
  user: {
    userId: 'xyz',
    email: '[email protected]',
    productAccess: []
  }
}

3. Authenticated with purchases

productAccess lists product IDs the customer currently has access to—for example:

Staying in sync: userChange

The reliable way to refresh your app when login, logout, or entitlements change is the userChange event. Subscribe to it and re-read user state or update your UI from the event payload. That is the primary mechanism to keep navigation, paywalls, and feature gates aligned with tiun.

circle-info

Prefer userChange over polling tiun.user when you need accurate, up-to-date access state.

Last updated

Was this helpful?