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 install ky
yarn add ky
pnpm add ky
Import
import ky from 'ky';
Quick Example
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
| Package | ky |
| Category | HTTP |
| Weekly Downloads | 2M+ |
| License | MIT |
| Install | npm install ky |
Related Packages
Axios is a promise-based HTTP client for the browser and Node.js that provides an elegant and powerf…
Got is a human-friendly and powerful HTTP request library for Node.js that provides an extensive fea…
Node-fetch is a lightweight module that brings the browser's Fetch API to Node.js, providing a famil…
Undici is a high-performance HTTP/1.1 client for Node.js, developed by the Node.js team and serving …
SuperAgent is a progressive HTTP request library for Node.js and the browser that provides a flexibl…
Browse npm Packages by Category
Explore our reference of 200 popular npm packages with install commands, examples, and quick-start guides.