Skip to main content
The zitejs/auth module gives your frontend the signed-in user and sign-in/out actions. In backend workflows, the same user is available as context.user. See Authentication for the concepts (access modes and user sync).

useAuth (frontend)

useAuth() returns: Both functions take an optional opts object: The User type is { id, email, firstName?, lastName?, … }. With user sync enabled, your users-table fields are merged in and typed, so user.plan or user.team are available.
In an internal app, users are signed in automatically, so loginWithRedirect and logout are not used (they throw if called). Use them in external apps.

context.user (backend)

Set authenticated: true on a workflow and read context.user:
The same synced fields available on the frontend User are available on context.user, and can be referenced in row-level permission filters via userField.