⚡ v2.0 — Now with full plugin architecture

Resilient Axios requests,
handled right

TypeScript-first retry library with concurrency control, request prioritization, token refresh, response caching, and circuit breaker — as composable plugins.

Get Started → Quick Start GitHub
$ npm install axios-retryer

npm version npm downloads bundle size TypeScript MIT
2,150
req/sec healthy path
4,285
req/sec peak burst
100%
cache hit rate
1070
tests passing
6
plugins
Why axios-retryer?

Everything your Axios client needs

Most retry helpers stop at "try again after a delay." Real apps need more.

🔄
Intelligent Retries
Automatic or manual modes with fully customizable strategies. Control which status codes, HTTP methods, and error types trigger retries.
🚦
Priority Queue
CRITICAL → LOW request priorities. Important requests always go first. Binary-heap queue with O(log n) operations for high throughput.
🔑
Token Refresh
Refreshes auth tokens when 401s occur, queues concurrent requests during refresh, replays them with the new token. Works with GraphQL too.
Concurrency Control
Set maxConcurrentRequests to cap parallel traffic. Excess requests queue automatically with optional per-request priorities.
🛡️
Circuit Breaker
Trips open after N failures, fast-fails requests during recovery, tests with configurable half-open probes. Sliding window analysis included.
💾
Response Caching
In-memory cache with TTR, exact/prefix/regex invalidation, per-request overrides, and a custom storage adapter contract for Redis or Memcached.
📊
Metrics & Observability
Optional MetricsPlugin for retry counters, success rates, timer health, and onMetricsUpdated events for dashboards and alerting.
🧩
Plugin Architecture
Core stays small. Add token refresh, caching, circuit breaking, metrics, sanitization, and dependency gating only when you need them.
🌳
Tree-Shakeable
Each plugin ships as a focused entry point. Only what you import ends up in your bundle. No side effects at import time.

From zero to resilient in 5 lines

Wrap your Axios instance, add plugins, make requests. The axiosInstance property is a drop-in replacement for your existing Axios usage.

Read full guide →
import { createRetryer } from 'axios-retryer';
import { createTokenRefreshPlugin } from 'axios-retryer/plugins/TokenRefreshPlugin';
import { createCircuitBreaker } from 'axios-retryer/plugins/CircuitBreakerPlugin';

// Chain .use() so TypeScript merges plugin events on `retryer`
const retryer = createRetryer({
  retries: 3,
  maxConcurrentRequests: 10,
})
  .use(
    createTokenRefreshPlugin(async (axios) => {
      const { data } = await axios.post('/auth/refresh');
      return { token: data.accessToken };
    }),
  )
  .use(
    createCircuitBreaker({
      failureThreshold: 5,
      openTimeout: 30_000,
    }),
  );

// Use exactly like Axios
const { data } = await retryer.axiosInstance.get('/api/users');
Plugin Ecosystem

Add only what you need

Each plugin is a separate tree-shakeable entry point. The core stays lean.

🔑
TokenRefreshPlugin
axios-retryer/plugins/TokenRefreshPlugin
Auto-refresh access tokens on 401. Queue concurrent requests during refresh, replay them with new token.
🛡️
CircuitBreakerPlugin
axios-retryer/plugins/CircuitBreakerPlugin
Trip open after N failures. Fail-fast during recovery. Test with half-open probes. Sliding window analysis.
💾
CachingPlugin
axios-retryer/plugins/CachingPlugin
Cache GET responses. Exact/prefix invalidation, per-request TTR override, custom storage adapters.
💾
ManualRetryPlugin
axios-retryer/plugins/ManualRetryPlugin
Store failed requests, replay them on reconnect. Offline-first patterns, idempotency safeguards.
📊
MetricsPlugin
axios-retryer/plugins/MetricsPlugin
Retry counters, timer health, onMetricsUpdated events. Zero cost without the plugin.
🔒
DebugSanitizationPlugin
axios-retryer/plugins/DebugSanitizationPlugin
Redact headers, fields, and URL params in debug logs. Safe verbose logging in non-prod environments.
🔗
Priority blocking
blockingPriorityThreshold option
Block lower-priority requests until critical ones resolve. Built into the core — no plugin needed.

How does it compare?

Feature axios-retryer axios-retry retry-axios
Automatic & Manual Modes✅ Both❌ Auto only❌ Auto only
Concurrency Control✅ Yes❌ No❌ No
Priority Queue✅ CRITICAL→LOW❌ No❌ No
Token Refresh Plugin✅ Built-in❌ Manual❌ Manual
Circuit Breaker✅ Built-in❌ No❌ No
Response Caching✅ Built-in❌ No❌ No
Cancellation✅ Full❌ No❌ No
Plugin Architecture✅ Yes❌ No❌ No
Metrics & Observability✅ Rich⚠️ Basic⚠️ Basic
TypeScript Support✅ First-class⚠️ Basic⚠️ Basic
Tree-Shakeable✅ Yes❌ No❌ No

Ready to make your API calls resilient?

Install in seconds. Add the plugins that make sense for your app.

Get Started → View Examples