npmkyv1.14.3
npmBeginner-friendly

ky

Tiny and elegant HTTP client based on the Fetch API

httpfetchbrowserlightweightapi-clientrequestrequestshttpsfetchingget
The Problem

The fetch API is great but verbose for common patterns: checking response.ok manually, parsing JSON, setting timeouts, and adding retry logic each require boilerplate. Axios solves this but adds 13KB and XMLHttpRequest for a browser-only app that already has fetch. Ky wraps fetch with the ergonomics you actually want in under 2KB.

Mental Model

Ky is fetch with sensible defaults: it throws on non-2xx responses, parses JSON automatically with .json(), and accepts an options object that extends the RequestInit interface. Hooks replace axios interceptors โ€” beforeRequest, afterResponse, and beforeRetry give you the same insertion points.

60-second start

Install ky

npm install ky
import { } from 'ky';

Use it when

Use Ky in browser-only or Deno applications where bundle size matters and you don't need Node.js compatibility. It's a direct replacement for axios in these contexts with a fraction of the footprint.

Skip it when

Ky doesn't support Node.js's older http module (though it works in Node 18+ with native fetch). For isomorphic code (same HTTP client in browser and Node), use axios or got. For React apps that need caching and state, React Query provides the better abstraction.

Alternatives
axiosWorks in both browser and Node.js with XMLHttpRequest fallback โ€” use when you need isomorphic support
gotNode.js-first HTTP client with streams, pagination, and retry โ€” the right choice for server-side Node code
fetchBuilt-in and zero-KB โ€” sufficient for simple requests without retry or hooks

Ready to explore the full API?

See every class, function, and relationship in an interactive graph.