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 any by 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 Response

Key components:

ComponentPurpose
IgniterCallerEntry point — creates the builder
IgniterCallerBuilderImmutable configuration chain
IgniterCallerManagerRuntime engine that executes requests
IgniterCallerRequestBuilderFluent per-request API
IgniterCallerSchemaType-safe schema definitions with validation
IgniterCallerMockTyped mock registry for testing

Quick Start

Install the Package

npm install @igniter-js/caller
pnpm add @igniter-js/caller
yarn add @igniter-js/caller
bun add @igniter-js/caller

Create Your Client

lib/api.ts
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 fetch directly)
  • ❌ You need GraphQL support (consider urql or Apollo)

Next Steps