The React adapter for @tahanabavi/typefetch-query-core:
useQuery, useMutation, and a provider. Deliberately thin — the engine already
exposes subscribe / getSnapshot, so each hook is that contract handed to
useSyncExternalStore. All caching, staleness, and invalidation live in the
core.
pnpm add @tahanabavi/typefetch-reactReact >=18 is a peer dependency (the hooks rely on useSyncExternalStore).
@tahanabavi/typefetch-query-core is re-exported, so a QueryClient needs no
second direct dependency.
Setup
Build a client (declaring invalidation once) and put it in scope:
import { QueryClient, TypeFetchProvider } from "@tahanabavi/typefetch-react";
import { api } from "./api"; // a typefetch ApiClient
const client = new QueryClient({
relations: { "user.updateUser": ["user.getUser"] },
});
export function Root() {
return (
<TypeFetchProvider client={client}>
<App />
</TypeFetchProvider>
);
}