# Comparison

> Why choose OpenAPI React Query Codegen over Orval, Kubb, Hey API or openapi-react-query. Generation time, install size and type errors measured, what each tool generates for TanStack Query, and when another tool fits better.

Orval, Kubb, Hey API and openapi-react-query also turn an OpenAPI document into code for TanStack Query. This library is the one built only for React and TanStack Query v5, and that focus is where its advantages come from.

## What sets it apart

* **Everything is generated, with nothing to configure.** One command writes a hook, a suspense hook, a `queryOptions` factory, a prefetch function, an `ensureQueryData` function and a key function for every GET operation, and a mutation hook for the rest. With Orval and Kubb several of these are options you turn on. Hey API, and Kubb by default, generate options factories that you wire to the hooks yourself.
* **It is the fastest on every specification we measured.** The GitHub REST API (1,272 operations) takes 0.46 seconds. The other four take between 2.10 and 4.31 seconds.
* **It installs the least.** The generator adds 9 packages to a project. The others add between 35 and 91.
* **Its output compiles.** For the Stripe and GitHub APIs, `tsc` with `strict` reports no error in the generated code. That is not true of every generator: see the table below.
* **Server rendering is covered.** It is the only tool here that generates `ensureQueryData` functions, and prefetch functions come without an option. There are examples for [Next.js](/examples/nextjs/), [React Router](/examples/react-router/) and [TanStack Router](/examples/tanstack-router/).
* **It is made for CI and for coding agents.** [`--check`](/guides/ci-and-agents/) fails the build when the committed output is out of date, `--json` prints errors as JSON, and [`--agentsMd`](/guides/ci-and-agents/#coding-agents-a-guide-in-your-agentsmd) keeps a guide in your `AGENTS.md` that cut what an agent had to read by a quarter to a third in our runs.
* **The output is stable.** The client and the hooks come from one package and change in a breaking way only in a major version, with a migration guide.

## Measured

| Tool                            | Generation time, GitHub REST API (1,272 operations) | Packages added | Type errors in the output, Stripe / GitHub |
| ------------------------------- | --------------------------------------------------- | -------------- | ------------------------------------------ |
| **openapi-react-query-codegen** | 0.46 s                                              | 9              | 0 / 0                                      |
| openapi-typescript              | 2.10 s                                              | 35             | 0 / 0                                      |
| Kubb                            | 2.98 s                                              | 91             | 0 / 0                                      |
| @hey-api/openapi-ts             | 2.98 s                                              | 51             | 274 / 0                                    |
| Orval                           | 4.31 s                                              | 89             | 219 / 1                                    |

How these were measured, the versions and the other specifications are on the [Benchmarks](/guides/benchmarks/) page. The scripts are in the repository, so you can run them yourself.

## Feature by feature

|                              | This library                               | Orval                                     | Kubb                              | Hey API                                    | openapi-react-query                                |
| ---------------------------- | ------------------------------------------ | ----------------------------------------- | --------------------------------- | ------------------------------------------ | -------------------------------------------------- |
| Hooks per operation          | Yes, always                                | Yes                                       | With `hooks: true`                | Not in the documented output               | No generated code: `$api.useQuery("get", "/pets")` |
| Suspense hooks               | Yes, always                                | With `useSuspenseQuery`                   | With `suspense`                   | No                                         | `$api.useSuspenseQuery`                            |
| Prefetch functions           | Yes, always                                | With `usePrefetch`                        | No                                | No                                         | No                                                 |
| `ensureQueryData` functions  | Yes, always                                | No                                        | No                                | No                                         | No                                                 |
| `queryOptions` factories     | Yes                                        | Yes (`getXxxQueryOptions`)                | Yes, the default output           | Yes, the default output                    | `$api.queryOptions(...)`                           |
| Query key functions          | Yes                                        | Yes                                       | Yes                               | Yes                                        | No, the key is `[method, path, params]`            |
| Infinite queries             | Found by the `--pageParam` query parameter | `useInfinite` and `useInfiniteQueryParam` | `infinite` option                 | Found by pagination keywords               | At the call site                                   |
| Check for stale output in CI | `--check`                                  | `--outdated`                              | `--dry-run` shows planned changes | No                                         | `--check`                                          |
| Errors as JSON               | `--json`                                   | No                                        | `--reporter json`                 | No                                         | No                                                 |
| Release line                 | SemVer, v4 in beta                         | v8                                        | v5                                | Before 1.0                                 | Maintenance mode                                   |
| Configuration                | Command line flags                         | `orval.config.ts`                         | `kubb.config.ts`                  | `openapi-ts.config.ts`                     | Command line flags                                 |
| HTTP client                  | fetch or axios, generated into the output  | fetch, axios or your own                  | fetch, axios or your own          | Fetch, Axios, Ky, OFetch and others        | fetch, through the `openapi-fetch` package         |
| Frameworks                   | React                                      | React, Vue, Svelte, Solid, Angular        | React, Vue                        | React, Vue, Svelte, Solid, Angular, Preact | React                                              |
| Other data libraries         | No                                         | SWR, Pinia Colada                         | SWR                               | Pinia Colada                               | No                                                 |
| Schema validation            | JSON Schema constants                      | Zod, Valibot, Effect                      | Zod                               | Zod, Valibot                               | No                                                 |
| Mocks                        | MSW handlers with fixed values             | MSW and Faker                             | MSW and Faker                     | In progress                                | No                                                 |

Where a tool has no helper of its own, such as prefetching with Kubb or Hey API, you pass its `queryOptions` factory to `queryClient.prefetchQuery` or `queryClient.ensureQueryData` yourself.

The table was checked on 2026-11-15 against the documentation of Orval 8.48.0, Kubb 5.20.1 with `@kubb/plugin-react-query` 5.10.3, `@hey-api/openapi-ts` 0.99.0, and openapi-typescript 7.13.0 with openapi-react-query 0.5.4. If something is out of date, please [open an issue](https://github.com/7nohe/openapi-react-query-codegen/issues).

## Compared with Orval

Choose this library when you want React and TanStack Query without a configuration file. Suspense hooks, prefetch functions and `ensureQueryData` functions are there for every operation, where [Orval](https://orval.dev) has an option for each of the first two and none for the third. The generator adds 9 packages where Orval adds 89, generates the GitHub API in 0.46 seconds where Orval takes 4.31, and its output for the Stripe API compiles where Orval's had 219 type errors in our run.

Choose Orval when you need Vue, Svelte, Solid or Angular, SWR, Zod or Valibot schemas, mock data that is random, or per-operation overrides in a configuration file.

## Compared with Kubb

Choose this library when the fixed output is what you want. [Kubb](https://kubb.dev) is a plugin system: its React Query plugin generates `queryOptions` and `mutationOptions` factories by default and hooks when you set `hooks: true`, and you compose the rest in `kubb.config.ts` from plugins for the types, the client and the queries. Here there is one command and one package, 9 packages installed where that Kubb setup adds 91, and prefetch and `ensureQueryData` functions that Kubb does not generate.

Choose Kubb when you want to compose the output from plugins, write your own, or generate Vue Query, SWR or Zod code from the same configuration.

## Compared with Hey API

Choose this library when you want ready-made hooks. The documented output of the TanStack Query plugin of [Hey API](https://heyapi.dev) (`@hey-api/openapi-ts`) is options factories and query keys, which you pass to `useQuery`, `useInfiniteQuery` and `useMutation` yourself. It has no suspense, prefetch or `ensureQueryData` helpers. Hey API is before 1.0 and asks you to pin an exact version, while this library changes its output in a breaking way only in a major version. In our run, the output of 0.99.0 for the Stripe API had 274 type errors, and that version did not run in a project with TypeScript 7.

Up to v3 this library used `@hey-api/openapi-ts` to generate its client. Since v4 it has its own generator, which removed most of the packages it used to install. See [Migrating to v4](/guides/migrating-to-v4/).

Choose Hey API when you need a framework other than React, an HTTP client other than fetch and axios, or Zod or Valibot validation.

## Compared with openapi-typescript and openapi-react-query

Choose this library when you want a project that is maintained. [openapi-typescript](https://openapi-ts.dev) announced that it is [in maintenance mode](https://github.com/openapi-ts/openapi-typescript/issues/2874) from September 2026 and will get no more updates, and `openapi-fetch` and `openapi-react-query` with it. [Migrating from openapi-react-query](/guides/migrating-from-openapi-react-query/) shows the move step by step.

The approach differs too. openapi-typescript generates types only, and you call `$api.useQuery("get", "/pets/{petId}", ...)` with the method and the path as strings. Here every operation is a named hook (`useFindPetById`) that an editor can complete and a search can find, with key functions for invalidation and prefetch functions for the server, and no runtime package between your code and `fetch`.

That approach keeps very little generated code in the repository, which is its appeal. If that matters more to you than named hooks, it still works with the versions that exist today.

## When another tool fits better

This library is deliberately narrow. Another tool is the better choice when:

* You use Vue, Svelte, Solid or Angular. The hooks are for React.
* You want Zod or Valibot schemas generated for runtime validation. This library writes JSON Schema constants only.
* You want mock data that is random, or mocks that keep state. The generated MSW handlers answer with fixed values from the specification.
* You need an HTTP client other than fetch or axios.
* You want to change the shape of the generated code. There are flags, but no templates or plugins.

## In short

For a React application on TanStack Query v5, this library gives you the most generated code for the least setup: typed hooks and server-side helpers for every operation from one command, the smallest install and the fastest generation of the tools compared here, and output that compiles. Reach for one of the others when you need what it leaves out: another framework, runtime validation or a plugin system.
