A lightweight HTTP client built on the native fetch API, specifically designed for Cloudflare Workers and browser environments. Version 0.2.3 (as of mid-2025) provides zero-dependency HTTP utilities including timeout control, automatic retry with configurable strategies, request/response interceptors, streaming support, and TypeScript definitions. Differentiates from generic fetch wrappers like node-fetch or ky by being optimized for Cloudflare Workers' edge runtime, supporting Request object passthrough, and offering fluent builder patterns for common worker patterns like KV storage integration and environment handling. Active development with monthly releases.
npm install cloudflare-tools-fetchNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Create a FetchClient with timeout, perform GET and POST requests, and parse JSON responses.
// Old (removed): new FetchClient({timeout: 5000})
// New:
const client = new FetchClient();
client.setConfig({timeout: 5000});// Old: const stream = await client.fetchStream(url);
// New: const { data, response } = await client.fetchStream(url);const text = await client.get('url').then(r => r.text());Use on Cloudflare Workers or Node 18+ with global fetch. For Node.js <18, add polyfill: npm i -D node-fetch and import 'node-fetch'.
client.useRequestInterceptor(config => ({ ...config, headers: { Authorization: 'Bearer token' } }));Change to: import { FetchClient } from 'cloudflare-tools-fetch'Use Node 18+ or install global fetch polyfill: npm install node-fetch. Then add 'import fetch from "node-fetch";' before using the client.
Ensure you are calling .json() on a valid Response object, not on the raw body or on a rejected promise. Use response.ok to check status before parsing.
No dependency data recorded yet.