Skip to content

Installation

use-q ships as two installable packages plus an optional codegen CLI:

PackageWhat it provides
@use-q/api-clientFramework-agnostic createFetcher + types. Zero runtime dependencies.
@use-q/api-client-reactcreateApiClient and hooks (useQ, useM, …) on top of TanStack Query v5.
use-q-codegen (bin)OpenAPI → RouteDefinition map generator, distributed inside @use-q/api-client.
  • Node.js 18 or newer. use-q relies on global fetch and AbortController.
  • For the React layer: React 18+ and @tanstack/react-query 5.x.
Terminal window
# Core only — server scripts, edge workers, RSC, loaders
pnpm add @use-q/api-client
# Plus the React bindings
pnpm add @use-q/api-client @use-q/api-client-react @tanstack/react-query react react-dom

@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"
}
}

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"
}
}

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";

use-q-codegen is shipped as a bin from @use-q/api-client, so you can run it without a separate install:

Terminal window
pnpm exec use-q-codegen --input ./openapi.json --output ./src/api/schema.ts

Or with npm:

Terminal window
npx use-q-codegen --input ./openapi.json --output ./src/api/schema.ts

See Codegen for a full walkthrough.

Once everything’s installed, head to the Quick Start for a 5-minute end-to-end example.