🌐
HTTP2M+/wkMIT

ky

Ky is a tiny and elegant HTTP client based on the browser Fetch API, providing a more convenient API with sensible defaults for common use cases. At just a few

Installation

npm
npm install ky
yarn
yarn add ky
pnpm
pnpm add ky

Import

ESM
import ky from 'ky';

Quick Example

usage
const data = await ky.get('https://api.example.com/data').json();
console.log(data);

await ky.post('https://api.example.com/items', {
  json: { name: 'test' },
});

About ky

Ky is a tiny and elegant HTTP client based on the browser Fetch API, providing a more convenient API with sensible defaults for common use cases. At just a few kilobytes, Ky is significantly smaller than axios while offering many of the same convenience features. Ky provides automatic JSON parsing and stringification, retry on failure with configurable strategies, timeout support, hooks for request and response interception, URL prefix support for API base URLs, and proper error handling with HTTPError instances that include the response body. The library uses the native Fetch API under the hood, ensuring compatibility with modern browsers and any runtime that supports the Fetch standard. Ky's API is concise — ky.get(), ky.post(), ky.put(), ky.delete() — with method-specific shortcuts that return parsed JSON by default. The ky-universal package provides isomorphic support for both browser and Node.js environments. Ky is particularly well-suited for frontend applications and modern runtimes where a lightweight HTTP client with sensible defaults is preferred over heavier alternatives like Axios.

Quick Facts

Packageky
CategoryHTTP
Weekly Downloads2M+
LicenseMIT
Installnpm install ky

Related Packages

Browse npm Packages by Category

Explore our reference of 200 popular npm packages with install commands, examples, and quick-start guides.