Performance
Duplicate Fetches Are the Cheapest Win on a Slow Page
Two identical requests on mount is a bug with a number attached, not an architectural problem.
When auditing React and Next.js applications, I consistently see the same anti-pattern: five independent components on the page all making the exact same HTTP request on initial mount.
The navbar fetches `/api/user`. The profile badge fetches `/api/user`. The notification counter fetches `/api/user`. The sidebar fetches `/api/user`.
The cost of uncoordinated data fetching
Four identical requests are sent across the wire simultaneously. The browser opens multiple connections, the backend handles four queries, and React triggers multiple re-renders as each promise resolves out of order. It turns what should be a snappy dashboard into a jittery, sluggish experience.
Deduplication is a one-line abstraction
You do not need a massive state management library to fix this. A simple in-flight promise cache or lightweight hook deduplicates requests at the network layer:
const inflight = new Map();
export function fetchDedupe(url, options) {
if (inflight.has(url)) return inflight.get(url);
const promise = fetch(url, options)
.then((res) => res.json())
.finally(() => inflight.delete(url));
inflight.set(url, promise);
return promise;
}By caching the in-flight promise rather than just the final data, concurrent component mounts automatically latch onto the same single network call. One request leaves the browser, one response returns, and all components update in unison.