Skip to content

raf-query is early. The API can still change between minor releases, so use it at your own risk.

raf-query

Getting started

Installation

Install @raf-query/react, check the requirements, and pick the integration for your framework.

Install one package, @raf-query/react. It re-exports everything from @raf-query/core, so apps never import core directly.

npm install @raf-query/react
# or
pnpm add @raf-query/react
# or
yarn add @raf-query/react
# or
bun add @raf-query/react

Requirements

  • React 19.2 or newer. raf-query reads data with use() and relies on transitions, Actions and useOptimistic.
  • Node.js 22 or newer for server rendering.
  • TypeScript 5.5 or newer with strict, if you use TypeScript. Data, inputs and errors are inferred from your query factories, so most apps never write a type argument.

Pick your integration

raf-query needs a place that runs before rendering, to start the page's queries. Each framework has one, and its integration page sets up the client, the provider and server rendering:

FrameworkQueries start inGuide
TanStack Start or TanStack RouterRoute loaders, in the browser and during SSRTanStack Start
Next.js App Router, or another React Server Components frameworkServer componentsReact Server Components
React Router Framework ModeServer loaders, with a query client per requestReact Router
React Router SPA Mode or Data ModeclientLoaders, or a Data Router's loaders, in the browserReact Router
Anything elseYour router's loaders, or your own code before it navigatesStarting queries

Not sure which shape fits? The quick start builds the same page in the first three.

One entry point

Everything comes from @raf-query/react: the hooks, the client, hydration and the devtools. An app bundles only what it imports, so hydration and the devtools cost nothing until it uses them.

The one subpath, @raf-query/react/tanstack-router, is the TanStack Router integration. It needs @tanstack/react-router, an optional peer dependency. React Server Components and React Router need no integration entry.