refresh-fetch

JSON →
library 0.9.0 ·javascript
verified Jun 7, 2026

A wrapper around the fetch API that automatically handles authentication token refreshing. Current stable version is 0.9.0. It intercepts fetch responses, detects token expiry via a configurable `shouldRefreshToken` callback, performs token refresh via a `refreshToken` function, and retries the original request. Unlike manual token management, refresh-fetch abstracts the retry logic and ensures concurrent requests are serialized during token refresh. Requires ES6 Promise and fetch. Suitable for single-page apps using bearer tokens with expiry.