Installation
Install axios-retryer alongside Axios. The library has a single peer dependency.
Peer dependency
axios >= 1.7.4 is required. Earlier versions contain known security vulnerabilities (prototype pollution, DoS).
Package managers
npm install axios-retryer axios yarn add axios-retryer axios pnpm add axios-retryer axios Entry points
The library ships a compact core and one entry point per plugin:
// Core — retry manager, types, constants, error classes
import { createRetryer, RETRY_MODES, AXIOS_RETRYER_REQUEST_PRIORITIES } from 'axios-retryer';
// Plugins — import only what you use
import { createTokenRefreshPlugin } from 'axios-retryer/plugins/TokenRefreshPlugin';
import { createCircuitBreaker } from 'axios-retryer/plugins/CircuitBreakerPlugin';
import { createCachePlugin } from 'axios-retryer/plugins/CachingPlugin';
import { createManualRetryPlugin } from 'axios-retryer/plugins/ManualRetryPlugin';
import { createMetricsPlugin } from 'axios-retryer/plugins/MetricsPlugin';
import { createDebugSanitizationPlugin } from 'axios-retryer/plugins/DebugSanitizationPlugin';
// Convenience barrel (imports all plugins — loses tree-shaking)
import { createTokenRefreshPlugin, createMetricsPlugin } from 'axios-retryer/plugins'; Prefer subpath imports
Use focused subpath imports like axios-retryer/plugins/CachingPlugin so bundlers tree-shake unused plugins. The barrel axios-retryer/plugins bundles all plugins unconditionally (~52.6 KB raw / ~13.8 KB gzip). The barrel will be removed in v3.
Build formats
| Format | File | Use when |
|---|---|---|
| ESM | dist/index.mjs | Modern bundlers (Vite, Rollup, Webpack 5) |
| CJS | dist/index.cjs | Node.js CommonJS (require()) |
| Types | dist/index.d.ts | TypeScript |
| UMD / Browser | generated locally | Run pnpm build:browser in the repo |
TypeScript
TypeScript 4.0+ is supported. All public APIs ship with types. No @types/ package is needed.
// tsconfig.json — recommended minimum
{
"compilerOptions": {
"target": "ES2019",
"module": "ESNext",
"moduleResolution": "bundler", // or "node16" / "nodenext"
"strict": true
}
}