banner

Fetch.

Type-Safe, Fluent HTTP Client.

Build requests with confidence. Infer types automatically. Zero runtime surprises.

Fluent Builder Pattern

Construct immutable requests with a chainable API. TypeScript infers required parameters like dynamic paths automatically.

Configure Builder
Execute Request
const getUser = f.builder()
.def_method('GET')

await getUser.query()

Structured Router

Organize your API into a type-safe, tree-like structure. Enjoy autocomplete for every endpoint and dynamic path parameter.

1. Define Router
const api = f.router(BASE, {
auth: {
login: {...}
},
users: {
$id: {
GET: f.builder().build(),
posts: {...}
}
}
})
2. Type-Safe Usage
await api...
Select a route definition to generate its type-safe client usage

Input Validation

Enforce request body structures at compile time. The query method becomes type-safe based on your schema definition.

const createUser = f.builder()
.def_body(
t.object({
name: t.string,
age: t.number
}).parse
)
.build()

// Runtime Execution
await createUser.query({
body: {
name: "Alice",
age: 30
}
})

Response Inference

Automatically infer the return type of your request. Validate the server response at runtime and get typed data back.

1. Network Response
"Hello World"
2. Validate Schema
t.string.parse()
3. Inferred Type
string
const getText = f.builder()
.def_json()
.def_response(async ({ json }) => {
// 1. Fetch JSON
const raw = await json()
// 2. Validate
return t.string.parse(raw)
})
.build()

// 3. Result is typed!
const data = await getText.query()
^ (const) data: string

Middleware Pipeline

Intercept requests and responses with a reusable middleware stack. Add authentication, logging, or error handling globally.

Client
AUTH
LOG
Server
→ Request Phase: Add Headers→ Request Phase: Log StartProcessing...← Response Phase: Log End← Response Phase: Verify✓ Request Complete
const middleware = f.middleware()

// 1. Auth Middleware
middleware.use(async (req, next) =>
req.headers.set(...) // → Request
const res = await next(req)
return res // ← Response
}

// 2. Logging Middleware
middleware.use(async (req, next) =>
console.log('Start') // → Request
const res = await next(req)
console.log('End') // ← Response
return res
}

Lifecycle Hooks

Handle errors and lifecycle events gracefully. Isolate error logic from business logic using dedicated handlers.

Server Simulation
Console Output
Waiting for execution...
const request = f.builder()
.def_url('/api')
.def_request_handler(req => req)
.def_response(res => // 200 OK })
.def_fetch_err_handler(({status}) =>
if (status !== 200) log('Error')
.def_final_handler(() = >
log('Finally')
.build()

OpenAPI Generator

Bridge the gap between your backend and frontend. Generate production-ready, type-safe clients in seconds.

OpenAPI Spec
Generator CLI
Type-Safe Client
OpenAPI Spec
Type-Safe RouterAutocomplete paths
Zod ValidationRuntime safety
Auth MiddlewareSecure by default
Zero BoilerplateJust import & use