Size
3.7KB min + gzip, of a 4 KB budget
11.13KB with all 19 plugins, of 12 KB: about ky alone and half of axios
Jext / http v0.0.1
The response comes already parsed by Content-Type, and every outcome is { data, error }. The core reads JSON and text and has timeouts; retries, a cache, SSE, NDJSON, progress and 14 more are plugins that get into your bundle only when you import them.
import { http } from '@metapraxis/jext-http';
const { data: user, error } = await http
.send<User>('/api/users/1');
if (error) {
// 404, a dropped connection, a timeout:
// one if, no try/catch
console.log(error.status, error.data);
} else {
console.log(user.name);
}
3.7KB min + gzip, of a 4 KB budget
11.13KB with all 19 plugins, of 12 KB: about ky alone and half of axios
≈3×faster than ky on a plain GET
≈5×faster than axios on a plain GET
17×faster than axios on a 404: an error is a value, not a throw
| Scenario, µs | fetch | jext | ofetch | ky | axios |
|---|---|---|---|---|---|
| GET, a small JSON object | 5.70 | 7.22 | 7.04 | 21.16 | 40.83 |
| GET, a JSON array of 5000 objects (412 KB) | 2071 | 2195 | 2703 | 2751 | 2828 |
| POST, a JSON body, the created object back | 13.79 | 15.65 | 16.14 | 48.72 | 76.29 |
| A client: base URL, Authorization, a beforeRequest hook | 8.84 | 11.34 | 11.68 | 32.37 | 54.08 |
| GET, a 404 with a JSON body | 5.79 | 10.07 | 16.96 | 42.28 | 170.38 |
The median time of one request in microseconds, the middle of three runs, lower is better. fetch answers from memory, so the table shows the work of each client, not the network. The numbers move by about 5%, so a smaller difference is a tie.
Every outcome is { data, error }: a 404, a dropped connection and a timeout are one if, no try/catch.
ky, ofetch and axios throw on a 4xx or 5xx status by default
GET responses stay in memory, refresh in the background and are dropped after a POST to their path.
ky, ofetch and axios do not have it
The percent of a file sent to the server, in every browser.
fetch, ky and ofetch report no upload progress
A model or chat stream with an Authorization header and reconnects.
the browser EventSource cannot do it
Each plugin is its own import. A bundler keeps only the ones your app uses, so you pay for what you use.
retry
repeats a 503, a 429 or a dropped connection with backoff and Retry-After
+0.69 KB
cache
GET responses in memory, revalidated with ETag, dropped after a POST
+1.39 KB
sse
Server-Sent Events, also as a POST with a token
+1.55 KB
ndjson
NDJSON lines while they arrive
+0.86 KB
progress
upload and download progress
+1.05 KB
schema
data checked by any Standard Schema: Zod, Valibot, ArkType
+0.31 KB
auth
a token on every request, one refresh for all 401s
+0.32 KB
queue
no more than N requests at once and a rate limit
+1.01 KB
dedupe
identical requests at the same moment share one
+0.67 KB
hooks
steps before and after every request
+0.33 KB
paginate
for await over pages: Link header or a cursor
+0.23 KB
csv
CSV and TSV as rows
+0.27 KB
xml
XML as an object (through fast-xml-parser)
+0.14 KB
html
HTML as a Document
+0.07 KB
form
FormData and URLSearchParams
+0.09 KB
binary
files as Blob and ArrayBuffer
+0.15 KB
mock
answers from routes instead of the network, for tests
+0.47 KB
same-origin
the token never leaves your origin
+0.18 KB
decoder
a format of your own: YAML, TOML and others
+0.14 KB
793test files: unit, integration, feature, browser, size and speed
47lessons: each task next to fetch, XMLHttpRequest, axios, ky and ofetch
MITlicence, zero required dependencies