Skip to content

Auth Feature

Public Summary

Handles login, session persistence, token refresh, and route protection on the client side.

Internal Details

Files

FileRole
Login.jsxLogin page with form
PersistLogin.jsxWrapper that refreshes tokens on app load
RequireAuth.jsxRoute guard — redirects to login if unauthenticated
useAuth.jsHook to access auth state
useLogout.jsHook to clear session
useRefreshToken.jsHook to silently refresh access token

State Management

  • authStore (Zustand, persisted to localStorage): stores auth object and persist flag.
  • Access token kept in memory; refresh token in httpOnly cookie.

Route Protection Flow

Dependencies

DependencyUsage
authStoreAuth state persistence
fetchPublic / fetchPrivateAPI calls with auth retry

Source Anchors

PathRelevance
apps/client/src/features/auth/Login page, guards, auth hooks
apps/client/src/store/authStore.jsAuth state (Zustand, persisted)
apps/client/src/api/fetch.jsFetch wrappers with 401 retry

Obrok engineering documentation.