Introduction
A type-safe HTTP client for Igniter.js with automatic schema validation, caching, retries, and React integration. Built on native fetch.
The Missing Piece
Every modern application needs to talk to APIs. Whether you're fetching user data, sending form submissions, or syncing with third-party services, HTTP requests are everywhere. But making HTTP requests in TypeScript has always been frustrating:
- No type safety — responses are
anyby default, forcing you to cast or define interfaces manually - Boilerplate everywhere — error handling, retries, and caching require custom code for each request
- Client/server disconnect — types defined on the server don't automatically flow to the client
- Testing is painful — mocking fetch or axios requires complex setup
Caller solves all of these problems with a simple, fluent API.
// Define your API once
const api = IgniterCaller.create()
.withBaseUrl('https://api.example.com')
.withSchemas(myApiSchemas)
.build();
// Every request is fully typed
const { data, error } = await api.get('/users/:id')
.params({ id: '123' })
.execute();
// data is automatically typed as User — no manual interfaces!
console.log(data?.name);Zero Configuration
Caller works out of the box with no setup. IgniterCaller.create().build() is all you need to start making requests.
Why Caller?
Architecture
Caller follows a builder pattern similar to other Igniter.js packages:
IgniterCaller.create()
→ .withBaseUrl() / .withSchemas() / .withInterceptors()
→ .build()
→ IgniterCallerManager
→ .get() / .post() / .put() / .patch() / .delete()
→ IgniterCallerRequestBuilder
→ .params() / .body() / .retry() / .stale()
→ .execute()
→ Type-Safe ResponseKey components:
| Component | Purpose |
|---|---|
| IgniterCaller | Entry point — creates the builder |
| IgniterCallerBuilder | Immutable configuration chain |
| IgniterCallerManager | Runtime engine that executes requests |
| IgniterCallerRequestBuilder | Fluent per-request API |
| IgniterCallerSchema | Type-safe schema definitions with validation |
| IgniterCallerMock | Typed mock registry for testing |
Quick Start
Install the Package
npm install @igniter-js/callerpnpm add @igniter-js/calleryarn add @igniter-js/callerbun add @igniter-js/callerCreate Your Client
import { IgniterCaller } from '@igniter-js/caller';
export const api = IgniterCaller.create()
.withBaseUrl(process.env.API_URL || 'http://localhost:3000')
.build();Make Your First Request
import { api } from './lib/api';
async function fetchUsers() {
const { data, error } = await api.get('/users').execute();
if (error) {
console.error('Failed to fetch users:', error.message);
return [];
}
return data;
}That's it! You now have a working HTTP client. Continue to Quick Start for a guided tutorial, or jump to Core Concepts to learn about the builder pattern.
When to Use Caller
Caller is ideal for:
- ✅ Igniter.js applications — seamless integration with the framework
- ✅ Type-safe API clients — compile-time validation of your API contracts
- ✅ React/Next.js projects — built-in hooks and SSR support
- ✅ Microservices communication — retries, caching, and observability
- ✅ OpenAPI consumers — generate clients from specs with the CLI
Consider alternatives if:
- ❌ You need browser support for IE11 (Caller uses native fetch)
- ❌ You're building a simple script with one-off requests (use
fetchdirectly) - ❌ You need GraphQL support (consider urql or Apollo)
Next Steps
Quick Start
Make your first request in under 2 minutes
Installation
Complete setup guide with all configuration options
Comparison
See how Caller compares to Axios, ky, and ofetch
Request Builder
Deep dive into the fluent API for building requests
Schema Validation
Learn how to define type-safe API contracts
Real-World Examples
Production-ready patterns for common API workflows