Bun
HyperFetch runs on Bun with nothing extra. Its default adapter calls Bun's native fetch, so createClient,
createRequest and send() work the same way they do in Node.js and in the browser.
Purpose
- Nothing extra to install:
bun add @hyper-fetch/coreand you are done. - Fast scripts and servers: Typed requests with retries and caching in Bun scripts, jobs and servers.
- End-to-end types with Bun backends: Elysia and Hono on Bun give you a typed SDK without codegen.
Getting started
bun add @hyper-fetch/core
index.ts
import { createClient } from "@hyper-fetch/core";
const client = createClient({ url: "https://api.example.com" });
const getUsers = client.createRequest<{
response: { id: number; name: string }[];
}>()({
endpoint: "/users",
});
const { data, error } = await getUsers.send();
console.log(error ?? data);
bun run index.ts
Bun backends
If your backend runs on Bun, you can skip OpenAPI and read the types straight from your routes:
Elysia
A typed SDK for your Elysia app, with responses, errors and inputs read from your routes.
Hono
A typed SDK built from your Hono routes and validators, with no codegen.
Testing with bun test
Mock a request with setMock(), so bun test never reaches the network:
users.test.ts
import { expect, test } from "bun:test";
import { getUsers } from "./requests";
test("lists users", async () => {
getUsers.setMock(() => ({ data: [{ id: 1, name: "Ada" }], status: 200 }));
const { data } = await getUsers.send();
expect(data).toEqual([{ id: 1, name: "Ada" }]);
});
When it's helpful
- Bun scripts and servers that call other APIs and need retries and typed responses.
- Full-stack apps with an Elysia or Hono backend on Bun.
- Fast test suites with
bun testand mocked requests.
Summary
- HyperFetch runs on Bun's native
fetchwith no extra adapter. - Elysia and Hono give you a typed SDK from your Bun backend.
setMock()keepsbun testoff the network.
