Skip to content

@shkumbinhsn/fetcher

Type-safe fetch wrapper with validation and error handling for modern TypeScript applications

Features

🔒 Type Safety

Full TypeScript support with type inference for requests and responses

✅ Schema Validation

Response validation using any Standard Schema compatible library (Zod, Valibot, etc.)

🎯 Error Handling

Structured error handling with typed error responses and custom error classes

🚀 Familiar API

Extended RequestInit interface - works exactly like fetch with extra features

📦 Tiny Bundle

Minimal dependencies and tiny bundle size for optimal performance

🔧 Framework Agnostic

Works with any JavaScript framework or vanilla TypeScript/JavaScript

Quick Example

import { fetcher } from '@shkumbinhsn/fetcher';
import { z } from 'zod';
const UserSchema = z.object({
id: z.string(),
name: z.string(),
email: z.string().email()
});
// Fully typed response
const user = await fetcher('/api/users/123', {
schema: UserSchema
});
console.log(user.name); // TypeScript knows this is a string