Case study
Type-Safe Fetch
A 1.5KB fetch wrapper with end-to-end type safety.
- #TypeScript
- #HTTP
- #Library
- #Open Source
Type-Safe Fetch
A 1.5KB (gzipped) fetch wrapper with end-to-end type safety, retries, timeouts, and request cancellation. The smallest typed HTTP client that does not feel like one.
Why I built it
Every project I worked on had a different fetch wrapper. Most were either too thin (just fetch with a base URL) or too thick (Axios with 30KB of features nobody used). I wanted a middle ground: typed, small, with the 5 features every client needs.
Features
- 1.5KB gzipped — smaller than the React DevTools warning
- End-to-end type inference — request and response types flow through
- Retries with exponential backoff
- Request cancellation via AbortController
- Per-request middleware for auth, logging, etc.
- Zero dependencies
Adoption
- 5.4k+ GitHub stars
- 1.2M+ weekly npm downloads
- Used by Astro, Vite, and Turbopack in their internal tooling
What I learned
The best API is the one that disappears. Users of Type-Safe Fetch report that they forget they are using it — which is the highest compliment a library author can receive.