itty-fetcher is an ultra-compact (~650 bytes) typed wrapper around the native Fetch API, designed to eliminate boilerplate such as manually setting Content-Type headers, JSON encoding/decoding, and error handling. Version 1.0.10 is the latest stable release, maintained by the author of itty-router. It shifts the final response parsing, method/body handling, and base URL into a small, chainable, proxy-based interface. Differentiators include TypeScript generics for request/response types, composable response transforms via after hooks, and a runtime-minifiable snippet that fits in a tweet. The library is ESM-only and ships with TypeScript definitions.
npm install itty-fetcherNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Creates a reusable fetcher with base URL, headers, and response hook, then demonstrates typed GET and POST calls.
If you need different base URLs or headers, create separate fetcher instances.
Only use after hooks for logging or transformation; avoid throwing in them.
Set parse option to 'text' or 'blob' for non-JSON responses: api.get('/data.txt', { parse: 'text' })Specify the correct parse type: await api.get('/text', { parse: 'text' })Ensure the snippet is correctly copied (the minified snippet handles this). If using import, use fetcher({}) or fetcher(base, options).No dependency data recorded yet.