API client structure
Base utilities
File:lib/utils.ts
Query pattern
Each API file exports typed query functions:Using queries
In components
With suspense
Mutation pattern
In components
Server prefetching
File:lib/server/query-hydration.tsx
For SSR, prefetch queries server-side:
- Prefetches data on the server
- Dehydrates query cache
- Hydrates on client
- Avoids loading spinners on initial render
Query configuration
File:components/providers.tsx
Real-time invalidation
ActionCable subscriptions invalidate queries on updates:Error handling
Type generation
API types are manually maintained inlib/api/*.ts. Keep them in sync with backend response shapes.