A lightweight, fetch-compatible HTTP client (v3.0.0) that transparently deduplicates identical in-flight requests and caches responses to improve performance in complex web apps. Unlike raw fetch, it groups concurrent requests with the same URL, method, and body into a single network call, and can cache responses for subsequent requests. It exports a fetchDedupe function, cache management utilities, and error types. Works in browsers and Node 18+ with global fetch.
npm install fetch-dedupeNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Shows how to use fetchDedupe as a drop-in fetch replacement that dedupes concurrent requests.
Upgrade to Node 18 or later, or use a fetch polyfill like undici or node-fetch.
URL as first argument still works; no change needed.
Pass a function: responseType: (res) => res.status === 204 ? 'text' : 'json'
Use responseCache.clear() between tests or create isolated contexts.
Pass a custom requestKey to normalize body ordering.
Always add a .catch() or try/catch around fetchDedupe.
Change to: import { fetchDedupe } from 'fetch-dedupe';Install a fetch polyfill and set globalThis.fetch = require('node-fetch');Add a catch block: fetchDedupe('/api').catch(err => console.error(err));Set responseType explicitly or handle non-JSON responses with a function.
No dependency data recorded yet.