Skip to content

The Generated API Client

Everything under frontend/src/client/ is generated code — it doesn’t get hand-written, and it shouldn’t get hand-edited either. It’s produced from the backend’s own OpenAPI schema, so the frontend’s types always match what the backend actually returns.

From the repo root:

Terminal window
bun run generate-client

This exports the backend’s live OpenAPI schema, regenerates src/client/, and runs the linter over the result. Run it every time you change a backend route or model — new field, new endpoint, changed response shape, all of it. Skipping this is the #1 cause of “the frontend type doesn’t match what the backend actually sends.”

src/main.tsx configures the client once — base URL and how to attach the auth token (read from localStorage) — and every component after that just calls into it through TanStack Query:

useQuery({
queryKey: ["items"],
queryFn: () => ItemsService.readItems(),
})

You never write the fetch/axios call yourself — you call the generated *Service function, and TanStack Query handles caching and re-fetching around it.