Fetch-only transport
One code path on top of standard fetch — Node, Bun, Deno, Workers, and modern browsers without mandatory polyfills.
Interceptors, middleware, Standard Schema JSON, retry lifecycle hooks, and memory cache — fetch-only for Node 18+, the edge, and modern browsers.
Open in your assistant
Pre-fills a prompt that points at the docs site and . If the message box is empty, paste the prompt from the address bar or type it manually — URL prefill behavior depends on the product.
| Capability | openFetch | 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() | — | — |
| transformRequest / transformResponse | Ordered arrays on config | Built-in transform pipeline | Hooks (no config arrays) |
| Validated JSON (Standard Schema) | jsonSchema + fluent .json(schema) | Bring your own (e.g. Zod in transform) | .json(schema) |
| HTTP status gate | validateStatus + throwHttpErrors | validateStatus | throwHttpErrors |
| Native Request + sync init | request(Request) + init[] | Config-based (no first-class init[]) | Request + init hooks |
| Retry with backoff (opt-in) | Plugins + onAfterResponse / ForceRetry | Separate | Retry + afterResponse hook |
| GET memory cache (TTL / SWR) | createCacheMiddleware + store | Third-party / DIY | — |
| Uniform client response | OpenFetchResponse | AxiosResponse | Response / parsed |
| Errors, safe logs, URL guard | toShape, redact URL, mask headers, URL guard | AxiosError; DIY redaction | Typed errors; DIY redaction |
| Timeout vs user cancel | ERR_TIMEOUT vs ERR_CANCELED | Often AbortError for both | TimeoutError vs AbortError |
| Fluent client + memo | createFluentClient + .memo() | — | Native chaining (no bundled memo) |
| POST retry idempotency key | Opt-in auto header (retry plugin) | Manual / interceptors | Manual |
| Edge & RSC friendly | Uses fetch | Adapters | fetch |
Bundle size depends on your toolchain and imports. openFetch layers practical fetch ergonomics: Standard Schema JSON, status gates, Request + sync init, retry lifecycle hooks, ERR_TIMEOUT vs cancel — see Features & pipeline for the full diagram.
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, guards, safe logging, assertSafeHttpUrlSKILL.md skill bundle and skills.sh / Agent Skills format| 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, isHTTPError, isTimeoutError | Typed errors + guards |
SchemaValidationError, isSchemaValidationError | Standard Schema failures on JSON |
OpenFetchForceRetry, isOpenFetchForceRetry | Force another retry attempt from onAfterResponse |
| Standard Schema types | StandardSchemaV1, StandardSchemaV1InferOutput, … |
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.