Skip to main content
The frontend uses a typed API client layer with TanStack Query for server state management.

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:
This:
  1. Prefetches data on the server
  2. Dehydrates query cache
  3. Hydrates on client
  4. 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 in lib/api/*.ts. Keep them in sync with backend response shapes.