tanstack-fetch
| Install | |
|---|---|
npm install tanstack-fetch |
|
| Latest Version: | 1.7.1 |
| Vue: | 3 |
| License: | MIT |
| Last Updated: | Oct 21, 2026 |
| Links: | GitHub · npm |
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
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
- Playground
- StackBlitz examples
- Migrate from axios / ky / ofetch / fetch
- Doctor CLI —
npx tanstack-fetch doctor - What's new — 1.7.1
- Changelog
Not an official TanStack package — shaped for the same Query mental model.
License
Related Packages
The request strategy layer for JavaScript. 20+ ready-made strategies cut your re...
🌀 OpenAPI to TypeScript code generator. Production-grade SDKs, Zod schemas, Tan...
🌀 OpenAPI to TypeScript code generator. Production-grade SDKs, Zod schemas, Tan...
Type-safe Fetch HTTP client with retries, interceptors, validation, and multi-ho...
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 | |
| 1.6.0 | MIT | |
| 1.5.0 | MIT | |
| 1.4.2 | MIT | |
| 1.4.1 | MIT | |
| 1.4.0 | MIT | |
| 1.3.0 | MIT | |
| 1.2.1 | MIT | |
| 1.2.0 | MIT | |
| 1.1.0 | MIT | |
| 1.0.6 | MIT | |
| 1.0.5 | MIT | |
| 1.0.4 | MIT | |
| 1.0.3 | MIT | |
| 1.0.2 | MIT | |
| 1.0.1 | MIT | |
| 1.0.0 | MIT |