Wretch is a tiny TypeScript-friendly layer on fetch that simplifies JSON bodies, headers, errors, and reusable request configuration.
Overview
Wretch wraps the standard fetch API with an immutable chaining style so each configuration step returns a new instance safe to reuse. Helper methods set URLs, headers, auth, JSON payloads, signals, and middleware hooks before HTTP verbs execute the network call.
Catchers handle HTTP error codes with defaults that throw when responses are not successful, and addons add query strings, form encoding, abort timeouts, basic auth, and upload progress via optional modules. The core bundle stays around 1.8 KB gzipped.
Version 3 targets modern browsers plus Node.js 22 or newer, Deno, and Bun with native fetch. Earlier major versions support legacy environments documented in migration guides.
API reference and recipes cover token refresh, schema validation, file uploads, and typed client composition.
Key features
- Immutable request chaining
- JSON and body shorthand helpers
- HTTP error catcher hooks
- Addon query and form plugins
- TypeScript typed API
- Middleware interception
Use cases
- Browser apps calling REST APIs
- Node services needing fetch ergonomics
- Shared typed HTTP client modules