Installation
use-q ships as two installable packages plus an optional codegen CLI:
| Package | What it provides |
|---|---|
@use-q/api-client | Framework-agnostic createFetcher + types. Zero runtime dependencies. |
@use-q/api-client-react | createApiClient and hooks (useQ, useM, …) on top of TanStack Query v5. |
use-q-codegen (bin) | OpenAPI → RouteDefinition map generator, distributed inside @use-q/api-client. |
Requirements
Section titled “Requirements”- Node.js 18 or newer.
use-qrelies on globalfetchandAbortController. - For the React layer: React 18+ and
@tanstack/react-query5.x.
Install
Section titled “Install”# Core only — server scripts, edge workers, RSC, loaderspnpm add @use-q/api-client
# Plus the React bindingspnpm add @use-q/api-client @use-q/api-client-react @tanstack/react-query react react-domnpm install @use-q/api-client
npm install @use-q/api-client @use-q/api-client-react @tanstack/react-query react react-domyarn add @use-q/api-client
yarn add @use-q/api-client @use-q/api-client-react @tanstack/react-query react react-domPeer dependencies
Section titled “Peer dependencies”@use-q/api-client-react declares peer dependencies that you must install in your app:
{ "peerDependencies": { "@tanstack/react-query": "^5.0.0", "react": "^18.0.0 || ^19.0.0" }}TypeScript
Section titled “TypeScript”use-q is written in strict TypeScript with exactOptionalPropertyTypes and noUncheckedIndexedAccess. To get the best inference, enable strict mode in your tsconfig.json:
{ "compilerOptions": { "strict": true, "moduleResolution": "bundler", "target": "ES2020" }}Verifying the install
Section titled “Verifying the install”After installing, you should be able to import from each package without type errors:
import { createFetcher, isApiError } from "@use-q/api-client";import { createApiClient, ApiErrorBoundary } from "@use-q/api-client-react";Running the codegen CLI
Section titled “Running the codegen CLI”use-q-codegen is shipped as a bin from @use-q/api-client, so you can run it without a separate install:
pnpm exec use-q-codegen --input ./openapi.json --output ./src/api/schema.tsOr with npm:
npx use-q-codegen --input ./openapi.json --output ./src/api/schema.tsSee Codegen for a full walkthrough.
Once everything’s installed, head to the Quick Start for a 5-minute end-to-end example.