Skip to content

v1.6 • Utils • 2kb gzipped • MIT

FetchGuard

Retries, timeouts and circuit breaking wrapped around fetch, without replacing it.

★ 6.3kGitHub
↓ 10.8k / week● MIT● TS 5.0+
fetchguard-preview.png
Abstract preview graphic for FetchGuard

// why fetchguard

Still just fetch

Same signature, same response object. Wrap an existing call and nothing downstream needs to change.

● 0 deps● 2kb gzipped● tree-shakeable

// stack

Backoff that behaves

Exponential backoff with jitter, capped attempts, and retries only on the statuses that deserve one.

FetchGuard started as a single file in a client project and stayed small on purpose. It does one job, it does it in 2kb gzipped, and it has no runtime dependencies.

Getting started

Install it, import it, call it:

npm i fetchguard-js

Same signature, same response object. Wrap an existing call and nothing downstream needs to change.

What it does not do

It does not manage your state, style your components or ship a plugin system. Those are your decisions, and keeping them out is what keeps the bundle honest.

  • Real timeouts
  • Circuit breaking
  • MIT licensed, commercially friendly

Features

Real timeouts

Aborts through AbortController, so a slow response actually releases the connection.

Circuit breaking

A failing endpoint stops being hammered and gets a half-open probe instead.

Documented properly

Every public function has a worked example, not just a signature.

ESM and types

Ships module and CommonJS builds with hand-written type definitions and source maps.

Tree-shakes cleanly

Every export is side-effect free, so importing one function costs one function.

Tested to the edges

Ninety-eight percent branch coverage, with the awkward cases written first.

Get FetchGuard v1.6

5 files • .min.js 2kb • .zip 25kb • sha384 verified

Changelog

v1.6 Mar 18 2026 • latest
  • Circuit breaker with half-open probes
  • Jittered backoff by default
  • Retry budget shared across calls
v1.5.4 Jan 30 2026
  • Node 18 is now the minimum supported version
  • CommonJS build restored for older bundlers
v1.5.3 Dec 14 2025
  • Reworked the public API for consistency
  • Deprecated helpers removed
View full archive →

// related

Related products

Sep 10 • v2.0

ChartForge

Canvas charts in twelve lines. Responsive, accessible and dark-mode ready, with no D3 learning curve.

View →
Aug 30 • v3.2.1

MotionEase

Physics-based micro-animations with a single call. Spring curves that feel right without a tuning session.

View →
Aug 19 • v1.9.4

FormFlow

Validation and multi-step logic that works the same in React, Vue and vanilla. Your markup stays yours.

View →

Drop it in this afternoon.

MIT licensed. Commercial friendly. Five-minute setup.