Skip to content
TypeWire

@tahanabavi/typefetch-react

v1.1.0

React adapter for the TypeFetch query engine — useQuery, useMutation, TypeFetchProvider.

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.

bash
pnpm add @tahanabavi/typefetch-react

React >=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:

tsx
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>
);
}