Wiki
the map of any codebase

Overview

Overview

ky is a tiny HTTP client library built on top of the Fetch API. It is distributed as an npm package (ky, currently version 2.0.2 per package.json) and is consumed as an ES module — the package declares "type": "module" and exposes a single entry point ./distribution/index.js with types at ./distribution/index.d.ts (see package.json). The public surface includes the default ky export plus named exports such as HTTPError, KyError, SchemaValidationError, TimeoutError, isKyError, replaceOption, and the StandardSchemaV1 type, as imported by the test suite in test/main.ts.

In the ecosystem of HTTP clients, ky positions itself as a thin, modern wrapper over native fetch. The README explicitly notes that Node.js supports fetch natively and ky can be used directly there without additional polyfills (readme.md, FAQ). Compared to alternatives the README keywords reference — got, axios, node-fetch (package.json keywords) — ky differentiates by being small, ESM-only, and fetch-based, targeting modern browsers, Node.js, Bun, and Deno (readme.md intro).

Architecturally, this is a single-package library, not a monorepo. Source lives under source/ and is compiled with tsc --project tsconfig.dist.json into distribution/ (see the build script in package.json); only the distribution directory is shipped (files field). The codebase is primarily TypeScript (~17.5k LOC out of ~20.4k). It supports a ky.create(...) factory for preconfigured instances (readme.md FAQ), and exposes a hook system (e.g. afterResponse) and configuration options such as baseUrl, prefix, and throwHttpErrors (readme.md FAQ). Tests run via ava with xo linting, and CI (.github/workflows/main.yml) executes on Node.js latest, 24, and 22 on macOS, with Playwright installed for browser testing. Node >=22 is required (package.json engines).

Typical users are JavaScript/TypeScript developers writing applications or libraries that need an ergonomic HTTP client on top of fetch — across browsers (including SSR setups, addressed in the README FAQ), Node.js, Bun, and Deno. CDN distributions via jsdelivr, unpkg, and esm.sh (readme.md Install section) further indicate use in bundler-less browser contexts via <script type="module">. The project is maintained by Sindre Sorhus, Seth Holladay, and Szymon Marczak (readme.md Maintainers; mirrored in .github/funding.yml).

Cited sources· 7