A lightweight fetch wrapper with caching, retries, hooks, and timeouts — built for Bun and TypeScript.
Explore the getting-started guide »
Getting Started
·
API Reference
fetchify is a small wrapper around the native fetch API. It gives you a client with one method per HTTP verb, JSON handling, and typed errors, plus opt-in building blocks for the things you'd otherwise hand-roll around fetch:
- Caching — pluggable cache adapters (in-memory, Redis, Upstash) that read/write on
GETrequests, with opt-in invalidation on mutations - Retries — exponential backoff with jitter for transient failures (network errors, timeouts,
408/429/5xx) - Hooks — a
beforeRequesthook for attaching things like auth tokens right before a request goes out - Timeouts — per-client or per-request timeouts, composable with a caller-supplied
AbortSignal
See DOCS.md for the full API reference.
- Bun installed locally
Add fetchify as a dependency:
bun install @kamsteegsoftware/fetchifyFor a full walkthrough — making your first request, reading responses, and adding a cache adapter — see GETTING-STARTED.md.
import { createFetchify, FetchifyError } from "@kamsteegsoftware/fetchify";
const client = createFetchify({ baseUrl: "https://api.example.com" });
try {
const { data, response } = await client.get<User>("/users/1");
console.log(data);
} catch (error) {
if (error instanceof FetchifyError) {
console.error(error.status, error.data);
} else {
throw error;
}
}For the complete API surface — createFetchify, defineOptions, cache adapters, hooks, retries, and timeouts — see DOCS.md.
This project uses Changesets to manage version bumps and changelogs.
- When making a user-facing change, run
bun run changesetand follow the prompts to record what changed and how significant it is (major/minor/patch). - Before a release, run
bun run versionto consume all pending changesets, bump the version inpackage.json, and updateCHANGELOG.md.
Distributed under the MIT License. See LICENSE for more information.