Skip to main content

UseAuth

Provides access to the AuthContext which contains information about the active channel.

Signature
function useAuth(): void

Provides information about the current user & their authentication & authorization status.

Signature
interface AuthContext {    status: 'initial' | 'authenticated' | 'verifying' | 'unauthenticated';    authenticationError?: string;    isAuthenticated: boolean;    login: (username: string, password: string, onSuccess?: () => void) => void;    logout: (onSuccess?: () => void) => Promise<void>;    user: ResultOf<typeof CurrentUserQuery>['activeAdministrator'] | undefined;    channels: NonNullable<ResultOf<typeof CurrentUserQuery>['me']>['channels'] | undefined;    refreshCurrentUser: () => void;}

status

property'initial' | 'authenticated' | 'verifying' | 'unauthenticated'

The status of the authentication.

authenticationError

propertystring

The error message if the authentication fails.

isAuthenticated

propertyboolean

Whether the user is authenticated.

login

property(username: string, password: string, onSuccess?: () => void) => void

The function to login the user.

logout

property(onSuccess?: () => void) => Promise<void>

The function to logout the user.

user

propertyResultOf<typeof CurrentUserQuery>['activeAdministrator'] | undefined

The user object.

channels

propertyNonNullable<ResultOf<typeof CurrentUserQuery>['me']>['channels'] | undefined

The channels object.

refreshCurrentUser

property() => void

The function to refresh the current user.

Was this chapter helpful?
Report Issue
Edited Feb 2, 2026·Edit this page