Fetch-only transport
One code path on top of standard fetch — Node, Bun, Deno, Workers, and modern browsers without mandatory polyfills.
Interceptors, middleware, retry, and memory cache — zero hard dependency on XHR, built for Node 18+, browsers, and the edge.
| Capability | openFetchThis library | Axios | ky |
|---|---|---|---|
| Transport | fetch | XHR (default in browsers) | fetch |
| Runtime deps | Zero | Own stack | Zero |
| Instance & defaults | createClient | axios.create | ky.create |
| Request / response interceptors | Both | Both | Hooks only |
| Composable middleware | use() | — | — |
| Retry & memory cache (opt-in) | Plugins | Separate | Retry only |
| Uniform client response | OpenFetchResponse | AxiosResponse | Response / parsed |
| Edge & RSC friendly | Uses fetch | Adapters | fetch |
Bundle size depends on your toolchain and imports. The core idea: openFetch layers ergonomics on native fetch without switching transports.
The EscuelaJS categories API returns a JSON array. Below: openFetch, Axios, and ky.
openFetch — shared defaults, structured response, and room for interceptors/middleware:
import openFetch from "@hamdymohamedak/openfetch";
const res = await openFetch.get(
"https://api.escuelajs.co/api/v1/categories"
);
// res.data, res.status, res.headers, res.configAxios — familiar API; different transport defaults in the browser:
import axios from "axios";
const res = await axios.get(
"https://api.escuelajs.co/api/v1/categories"
);
// res.data, res.status, res.headers, res.configky — minimal API on top of fetch:
import ky from "ky";
const data = await ky
.get("https://api.escuelajs.co/api/v1/categories")
.json();baseURL, headers, timeouts, and unwrapResponse once per createClient instance.try/catch parsing.openFetch targets teams that want those benefits while staying on fetch everywhere the platform already provides it.
createClient, first requestsrequest(), bodies and query paramsrawResponse, merge rules, helper exports@hamdymohamedak/openfetch/plugins, @hamdymohamedak/openfetch/sugardispatch internals, use(), custom middlewarecreateCacheMiddleware, TTL / SWROpenFetchError, codes, safe logging, assertSafeHttpUrl| Export | Role |
|---|---|
| default | Pre-built createClient() instance |
createClient / create | New client with optional initialDefaults |
createFluentClient | Callable fluent URL chains (from /sugar) |
retry, timeout, hooks, debug, strictFetch | Middleware plugins (from /plugins) |
OpenFetchError, isOpenFetchError | Typed errors + type guard |
InterceptorManager | Low-level interceptor stack |
createRetryMiddleware | Retry middleware factory |
MemoryCacheStore, createCacheMiddleware, appendCacheKeyVaryHeaders | In-memory cache |
maskHeaderValues, cloneResponse, idempotency helpers | Logging and retry ergonomics |
| Types | OpenFetchConfig, OpenFetchResponse, Middleware, OpenFetchClient, etc. |
assertSafeHttpUrl | Optional SSRF-style guard for literal IP/localhost in URLs |
Node.js 18+ or any runtime with fetch and AbortController.
Browse all translations.