Docs

Retry Modes

axios-retryer supports two modes: Automatic (default) transparently retries failures; Manual stops after the first attempt and lets you decide when to replay.

Automatic mode

The default. Transient failures are retried up to retries times with configurable backoff, completely transparent to your application code.

import { createRetryer, RETRY_MODES, AXIOS_RETRYER_BACKOFF_TYPES } from 'axios-retryer';

const retryer = createRetryer({
  mode: RETRY_MODES.AUTOMATIC,     // default, can omit
  retries: 3,
  backoffType: AXIOS_RETRYER_BACKOFF_TYPES.EXPONENTIAL,
  retryableStatuses: [408, 429, [500, 599] as const],
});

// This GET will retry up to 3 times on 5xx / 429 / timeout
const { data } = await retryer.axiosInstance.get('/api/products');

What triggers a retry

  • Response status code matches retryableStatuses
  • Request method is in retryableMethods (default: GET, HEAD, OPTIONS)
  • Network error with no response
  • Custom retryStrategy.isRetryable() returns true

Manual mode

In manual mode the retry manager does not automatically retry. Each request either succeeds on the first attempt or fails immediately. Add ManualRetryPlugin when you want failed requests stored and replayed later — for example after reconnecting to the network.

import { createRetryer, RETRY_MODES } from 'axios-retryer';
import { createManualRetryPlugin } from 'axios-retryer/plugins/ManualRetryPlugin';

const manualRetry = createManualRetryPlugin({
  maxRequestsToStore: 50,
  manualRetryMaxAge: 5 * 60_000,   // Discard stored requests after 5 min
});

const retryer = createRetryer({ mode: RETRY_MODES.MANUAL }).use(manualRetry);

// Request fails → stored in ManualRetryPlugin
try {
  await retryer.axiosInstance.get('/api/data');
} catch {
  console.log('Failed — stored for later replay');
}

// Later — replay all stored failures
const results = await manualRetry.retryFailedRequests();
console.log(`${results.length} requests replayed`);

Offline / reconnect pattern

window.addEventListener('online', async () => {
  const results = await manualRetry.retryFailedRequests();
  showToast(`Synced ${results.length} pending request(s)`);
});

Choosing a mode

ScenarioMode
Standard API client — just handle transient errorsAUTOMATIC
You want to surface errors to the user and let them retryMANUAL
Offline-first SPA — queue when offline, sync on reconnectMANUAL + ManualRetryPlugin
Background worker that should keep trying indefinitelyAUTOMATIC with high retries
ℹ️
Manual mode without ManualRetryPlugin

RETRY_MODES.MANUAL alone means "don't retry automatically." You still get the concurrency queue and priority system — just no automatic replay. Add ManualRetryPlugin only when you need stored replay functionality.

Events → ManualRetryPlugin docs