pkgdocs/compare/react-query vs @trpc/server

Comparing

npm

react-query

Hooks for managing, caching and syncing asynchronous and remote data in React

1.6M/ wk
v3.39.3
vs
npm

@trpc/server

End-to-end type-safe APIs — share TypeScript types between server and client without code generation.

1.2M/ wk
v11.0.0
Metricreact-query@trpc/server
Ecosystemnpmnpm
DifficultyBeginner ✓Advanced
Weekly downloads1.6M↑1.2M
Latest versionv3.39.3v11.0.0
Recipes12↑

Tags

react-query only

reactdata-fetchingcachingserver-stateasynccachedatafetchgraphql

Shared

typescript

@trpc/server only

apirpcfullstacknextjs

When to use each

react-query

Use React Query for any React app that fetches server data: REST APIs, GraphQL, or any async function. It replaces 95% of the useEffect+useState patterns for data fetching and adds caching, background refetching, and optimistic updates for free.

@trpc/server

Full-stack TypeScript monorepos, Next.js apps where frontend and backend share a codebase, projects where you want type safety without REST/GraphQL ceremony.

When to skip each

react-query

React Query is for server state (data that lives on a server). For UI state (modals, form values, local toggles), use useState or Zustand. If you're already using a full data layer like Apollo Client for GraphQL, React Query is redundant.

@trpc/server

Public APIs consumed by third parties (use REST or GraphQL). Polyglot teams where some consumers aren't TypeScript. Microservices with many separate repos.

Sample recipes

react-query

  • Install react-query

@trpc/server

  • Define a tRPC router with queries
  • Call procedures from a client