A lightweight (1.4KB gzip) utility library for composing custom fetch wrappers with reusable middleware. Current stable version is 3.3.1, released regularly with a focus on TypeScript support and ESM compatibility. Differentiates from other fetch wrappers by providing a simple compose-based API (composeFetch) or pipeline pattern, alongside built-in middleware for default options, base URL injection, headers, query string serialization, JSON body serialization, and XSRF token handling. Supports both CommonJS and ESM, and ships TypeScript definitions.
npm install create-fetchNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Shows how to create a custom fetch with composed middleware including query string, default headers, and JSON body serialization.
If you need to preserve existing query params, manually parse the URL before calling fetch.
Replace default import with named import `composeFetch`.
Ensure middleware are arranged in application order now: first middleware wraps the innermost fetch.
Manually set Content-Type header for multipart forms or use browser's default for FormData.
Install and import a polyfill like 'cross-fetch/polyfill' at the entry point.
Use ES module import syntax: `import { composeFetch } from 'create-fetch'`.Replace `import createFetch from 'create-fetch'` with `import { composeFetch } from 'create-fetch'`.