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, sign-in methods, and auth hooks).
useAuth (frontend)
useAuth() returns:
Both functions are also exported directly from
zitejs/auth, and take an optional opts object:
There is one sign-in screen for both signing in and signing up: Zite works out which it is from the
email.
loginWithRedirect still accepts an initialView option, but ignores it.
The User type is { id, name, firstName?, lastName?, email, emailVerified, image, createdAt, updatedAt }.
To change the signed-in user’s name or picture, call updateProfile({ name?, firstName?, lastName?, image? })
from zitejs/auth.
In an internal app, users are signed in automatically, so you don’t need
loginWithRedirect or
logout. Use them in external apps.context.user (backend)
Setauthenticated: true on a workflow and read context.user:
context.user is { id, email, firstName?, lastName? }. The other User fields (name,
image, emailVerified, createdAt, updatedAt) are not sent to workflows. See
Workflows.
Sign-in hooks (zite.auth.ts)
When an app’s users live in another system (an Airtable roster, a CRM, an internal API), add azite.auth.ts file at the app root, next to its zite.config.json, that default-exports ziteAuth
from zitejs/auth/server:
Hooks run like workflow code, so they can use
zitejs/db and the app’s integrations. A hook that throws
or times out fails open, so a broken hook never locks people out. Write each hook as a literal method in
the file: which hooks exist is read from it at build time. Pair roster hooks with
"signup": "disabled" in the app’s authentication config so the roster is the only way in.