Releasestanstack-fetch 2.2.1: SSE reconnects and SSR fixes
tanstack-fetch 2.2.1 fixes 31 bugs: relative baseUrl, createTRPCFetch from npm, SSE reconnects with Last-Event-ID, SSR leaks in Svelte and Vue, a DevTools XSS.
Read the postOctober 1, 2026
1.6.0 experimented with a route map on createFetch<Routes>(). That is gone.
1.6.1 types URL params from :id / {id}, lets you pass a params map beside your response DTO, and optionally types body on write methods.
import type { NoParams } from 'tanstack-fetch'
type User = { id: string; name: string }
type Params = { id: number }
// params from the URL — no response generic
await api.get('/users/:id', { params: { id } })
await api.get('/users/:id') // ❌ missing id
// response only — options required (TS loses the path literal)
await api.get<User>('/users/:id') // ❌ missing options
await api.get<User[]>('/users', {})
// response + params map — path must include those keys as :id / {id}
await api.get<User, Params>('/users/:id', { params: { id } })
await api.get<User, Params>('/users/:id', { params: {} }) // ❌ missing id
await api.get<User, Params>('/users', { params: { id } }) // ❌ path has no :id
await api.get<User, { userId: number }>('/users/:id', { params: { userId: 1 } }) // ❌ no :userId
// post / put / patch — optional body type (third generic; use NoParams to skip params)
await api.post<User, NoParams, { name: string }>('/users', { body: { name: 'Ada' } })
await api.put<User, Params, { name: string }>('/users/:id', {
params: { id },
body: { name: 'Ada' },
})Same pattern for delete / upload; body typing on post / put / patch / request.
TypeScript cannot partially infer generics. Writing only api.get<User>(path) turns the path into string, so :id checks disappear. Pass your params map as the second type argument (and body as the third on write methods) to keep both.
| Before (1.6.0) | After (1.6.1) |
|---|---|
createFetch<Routes>() route map | dropped — use path + params map |
untyped / loose params | api.get<User, { id: number }>('/users/:id', …) |
npm install tanstack-fetch@1.6.1See also: Getting started, createFetch.
Releases·11 min read
tanstack-fetch 2.2.1 fixes 31 bugs: relative baseUrl, createTRPCFetch from npm, SSE reconnects with Last-Event-ID, SSR leaks in Svelte and Vue, a DevTools XSS.
Releases·3 min read
tanstack-fetch 2.1.0: abort during a retry delay, literal colons in paths, a safer refresh-token race, no stream-body retries, plus array query values.
Releases·2 min read
The tanstack-fetch core drops from 5.14KB to 3.57KB gzip: auth, status handlers and plugins become interceptors, and live APIs type path params like api.get.