react query helper

TYPESCRIPT IN. REUSABLE OPTIONS OUT.

Your API.
Query-ready.

Generate type-safe TanStack Query v5 query, mutation and infinite-query option factories from existing TypeScript API functions. Explore real generated examples, watch mode and CI checks.

Explore generated code ↓Quick start guide ↗

TanStack Query v5 · TypeScript · React 18 / 19 · MIT

01 / REAL GENERATOR OUTPUT

Keep the function. Skip the repetition.

These examples are generated from this repository’s actual analyzer and code generator at build time. Select a function to inspect its source and output.

Your API function

export const getUser = async (id: string) => ({ id, name: 'Ada' });

Generated options

import { getUser } from "./api";
import { queryOption as __rqh_query, infiniteOption as __rqh_infinite } from "@uiwwsw/react-query-helper";

export const getUserKey = ["users","api","getUser"] as const;
export const getUserQueryOption = __rqh_query(getUserKey, getUser);
export const getUserInfiniteQueryOption = __rqh_infinite(getUserKey, getUser);

This is a code-generation preview, not a live backend. Configure pagination and forward AbortSignal explicitly for your API.

02 / FROM INSTALL TO CI

One setup.
A repeatable workflow.

Generate once, watch during development and check generated output in CI. Reuse factories with useQuery, prefetchQuery and cache reads.

npm install @uiwwsw/react-query-helper@^2 @tanstack/react-query react
npx @uiwwsw/react-query-helper init
npx @uiwwsw/react-query-helper generate
npx @uiwwsw/react-query-helper watch
npx @uiwwsw/react-query-helper generate --check

What does React Query Helper generate?

Typed query keys and query, mutation and infinite-query option factories from top-level TypeScript API functions. Keep your existing HTTP client. It does not replace TanStack Query caching or retries.

Configuration, pagination and migration ↗