Context
Principle
Context is for cross-page app state. Server datasets belong to query hooks (TanStack), not context.
Current Contexts
auth- session identity, current user, auth actionssystem- system permission catalog (from/system/permissions)notifications- global notifications + unread countui- global busy/session UI statetheme- theme and persistence behavior
Aggregation
src/context/index.ts contains:
- static registry (
getContext,getContexts) - wrapper helper (
wrapWithContexts) - app wrapper (
AppContextProvider)
This allows one import point and consistent provider order.
Context Usage Guide
Naming
Provider function names use ...ContextProvider for clarity:
AuthContextProviderSystemContextProviderNotificationsContextProviderUiContextProviderThemeContextProvider
Import Pattern
Prefer importing from @/context for hooks/providers:
useAuth,usePermissions,useSystem,useNotifications,useUi,useTheme
Do / Don't
- Do put app-level state in context.
- Do not put large lists/details/tables in context.
- Do not duplicate the same server data in context and query cache.