tanstack-fetch

TanStack Query fetch client — typed errors, AbortSignal, SSR, SSE, upload. React, Vue/Nuxt, Solid, Angular, Svelte/SvelteKit. Lightweight axios/ky alternative (4.81KB gzip HTTP core).
3,225 3
Install
npm install tanstack-fetch
Latest Version:1.7.1
Vue:3
License:MIT
Last Updated:Oct 21, 2026
Links: GitHub  ·  npm
Maintainer: mohammad.garmabi

tanstack-fetch

Typed Fetch client designed for TanStack Query.

Returns data · throws FetchError · honors AbortSignal · SSR · SSE · React · Vue/Nuxt · Solid · Angular · Svelte · tRPC · DevTools

npm version npm downloads bundle size license CI

Docs

→ mohamadgarmabi.github.io/tanstack-fetch

Guides, API, playground, Vue/Nuxt, SSR, SSE, upload, tRPC, DevTools, and comparison live on the site.

Install

npm install tanstack-fetch @tanstack/react-query
# Vue / Nuxt
npm install tanstack-fetch vue
import { createFetch } from 'tanstack-fetch'
import { useQuery } from '@tanstack/react-query'

const api = createFetch({ baseUrl: 'https://api.example.com' })

useQuery({
  queryKey: ['users'],
  queryFn: ({ signal }) => api.get<User[]>('/users', { signal }),
})

Entry points

Import Use gzip
tanstack-fetch HTTP 4.81KB
tanstack-fetch/sse HTTP + api.sse() 5.94KB
tanstack-fetch/plugins Interceptor factories 1.13KB
tanstack-fetch/react FetchProvider, useFetch, useSse 0.81KB
tanstack-fetch/vue createFetchPlugin, useFetch, useSse 0.78KB
tanstack-fetch/solid FetchProvider, useFetch, useSse optional
tanstack-fetch/svelte setFetchClient, useFetch, useSse optional
tanstack-fetch/angular provideFetchClient, injectFetch, useSse optional
tanstack-fetch/trpc tRPC link 3.16KB
tanstack-fetch/devtools Request dock 8.32KB

Minified ESM, gzip measured locally after npm run build (npm run size).

Compared to axios / ky / ofetch

Need tanstack-fetch axios ky ofetch
Drop into TanStack Query queryFn Returns data, throws, takes signal Adapt Adapt Adapt
Typed error with status / body FetchError + isFetchError Partial Partial Partial
Handlers for 401–429 First-class Custom Custom Custom
Refresh token + single-flight Built-in interceptor Custom Custom Custom
Next.js SSR cookies ssr-forward Custom Custom Custom
SSE with Authorization tanstack-fetch/sse No No No
File upload + progress api.upload() Yes Limited Limited
tRPC transport tanstack-fetch/trpc No No No
Bundle (HTTP core) 4.81KB gzip Larger Small Small

Full write-up: Comparison

Try it

Not an official TanStack package — shaped for the same Query mental model.

License

MIT · Mohammad Garmabi

Related Packages

alova

The request strategy layer for JavaScript. 20+ ready-made strategies cut your re...

423,897 4,022
@hey-api/openapi-ts

🌀 OpenAPI to TypeScript code generator. Production-grade SDKs, Zod schemas, Tan...

127,850,437 5,511
@ohos-ports/openapi-ts

🌀 OpenAPI to TypeScript code generator. Production-grade SDKs, Zod schemas, Tan...

0 6
@poluru-labs/fetchwise

Type-safe Fetch HTTP client with retries, interceptors, validation, and multi-ho...

1,102 2
consentlayer

Consent-first analytics for the browser and server: one API in front of GA4, Met...

0 1

Version History

Version Released License
1.7.1 MIT
1.7.0 MIT
1.6.3 MIT
1.6.2 MIT
1.6.1 MIT