Skip to Content
⚠️Active Development Notice: TimeTiles is under active development. Information may be placeholder content or not up-to-date.

web


web / lib/hooks/use-auth-queries

lib/hooks/use-auth-queries

React Query hooks for authentication state.

Provides the current user query and derived auth state booleans. Separated from mutation hooks to enforce clear module boundaries.

Interfaces

CurrentUserResponse

Payload CMS /api/users/me response shape.

Properties

user

user: User | null

Variables

authKeys

const authKeys: object

Type Declaration

currentUser

currentUser: readonly ["auth", "current-user"]

Functions

fetchCurrentUser()

fetchCurrentUser(): Promise<CurrentUserResponse>

Fetch the current user from /api/users/me.

Swallows expected auth failures (401/403) as { user: null }. Rethrows transport and server errors so React Query surfaces them.

Returns

Promise<CurrentUserResponse>


useCurrentUserQuery()

useCurrentUserQuery(options?): UseQueryResult<CurrentUserResponse, Error>

Query hook for the current authenticated user.

Disabled by default — callers opt in via enabled.

Parameters

options?
enabled?

boolean

Returns

UseQueryResult<CurrentUserResponse, Error>


useAuthState()

useAuthState(): object

Derive auth booleans from the current user query.

Single source of truth for client-side auth state. Components should use this instead of maintaining their own auth state copies.

Returns

object

isAuthenticated

isAuthenticated: boolean

isEmailVerified

isEmailVerified: boolean

userId

userId: number | null

isLoading

isLoading: boolean

user

user: User | null

Last updated on