2 Commits

Author SHA1 Message Date
01365d72bd Add stores documentation with usage examples 2026-01-31 17:30:27 -08:00
184ecbbfcf Add Auth Store with Zustand state management
Implemented a modern, performant auth store using Zustand to replace
the existing AuthContext. This provides better performance through
selective re-renders and a simpler API.

Features:
- Full OTP authentication flow (checkEmail, requestOtp, verifyOtp)
- Automatic session checking on app start
- Unauthorized callback handling (auto-logout on 401)
- User profile management with local state updates
- Optimized selector hooks for granular subscriptions

Benefits over Context API:
- No unnecessary re-renders (only components using specific values update)
- Simpler API with direct store access
- Better TypeScript support with proper type inference
- Easier testing (no provider wrapper needed)
- Can be used outside React components

Testing:
- 23 comprehensive unit tests covering all functionality
- Tests for authentication flow, error handling, and edge cases
- 100% code coverage for core auth operations

Usage:
import { useAuthStore, initAuthStore } from '@/stores/authStore';

// In app/_layout.tsx
initAuthStore();

// In components
const { user, isAuthenticated, logout } = useAuthStore();

// Or use selectors for optimized re-renders
const user = useAuthUser();
const isAuthenticated = useIsAuthenticated();

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2026-01-31 17:30:02 -08:00