React hook that wraps the Fetch API and automatically aborts in-flight requests when the component unmounts or a new request is initiated. Version 3.0.3 is current stable with no regular release cadence; niche alternative to SWR/React Query for simple cases. Differentiator: minimal API (only one hook), no caching, no deduplication, built-in abort controller logic.
npm install use-abortable-fetchNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Shows basic usage of useAbortableFetch hook with loading, error, and data states.
Update to v3.x and remove extra .json() call; data is the response body.
Migrate to v3.x: call hook with URL string or options object with 'url' property.
Use useMemo or external caching if repeated fetches are undesirable.
Check response.ok or handle error status in onError callback or manually.
Normalize error handling: if (error instanceof Error) ... else ...
Replace import { useAbortableFetch } with import useAbortableFetch.Use const useAbortableFetch = require('use-abortable-fetch').default; or switch to ES import.Ensure URL is correct and CORS allows request; check if component unmounts prematurely.