@mrsamdev/axios-token-refresh
axios token refresh plugin with queued retries and clean interceptor lifecycle

When access tokens expire, requests fail at once and apps often re-run refresh logic multiple times. This package centralizes token refresh, queues failed requests, and replays them after refresh succeeds.

Lightweight TypeScript utility for Axios. Includes configurable refresh strategy, request deduping, automatic auth header injection, timeout handling, and a small tryCatch helper.

pnpm add @mrsamdev/axios-token-refresh
import axios from "axios";
import { createRefreshTokenPlugin } from "@mrsamdev/axios-token-refresh";

const client = axios.create({ baseURL: "/api" });
const cleanup = createRefreshTokenPlugin({
refreshTokenFn: async () => "new-token",
getAuthToken: () => localStorage.getItem("token"),
})(client);

// call cleanup() when you want to eject interceptors