# ky-universal

> Use Ky in both Node.js and browsers

Latest version **1.0.0** (published 2026-03-28) · MIT license · 0 weekly downloads

> **Deprecated.** This package is deprecated.

## Install

```sh
npm install ky-universal
pnpm add ky-universal
yarn add ky-universal
bun add ky-universal
```

## Health

**Score 10/100 (F)** — status: deprecated.

Negative: deprecated.

## Facts

| | |
|---|---|
| Version | 1.0.0 |
| Published | 2026-03-28 |
| First published | 2019-02-22 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM |
| Node | >=16 |
| Dependencies | 1 |
| Unpacked size | 6.4 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 670 |
| Author | Sindre Sorhus |
| Maintainers | sindresorhus |
| Keywords | ky, universal, isomorphic, browser, browsers, node, react, vue, ssr, fetch, request, requests, http, https, fetching, get, url, curl, wget, net, network, ajax, api, rest, xhr, browser, got, axios, node-fetch |

## Links

- npm: https://www.npmjs.com/package/ky-universal
- Repository: https://github.com/sindresorhus/ky-universal
- Homepage: https://github.com/sindresorhus/ky-universal#readme
- Issues: https://github.com/sindresorhus/ky-universal/issues
- Funding: https://github.com/sindresorhus/ky-universal?sponsor=1
- npm.io page: https://npm.io/package/ky-universal

## Dependencies (1)

- [node-fetch](https://npm.io/package/node-fetch.md) ^3.3.2

## Alternatives

- [launchdarkly-js-client-sdk](https://npm.io/package/launchdarkly-js-client-sdk.md) — 2.5M weekly downloads
- [@elastic/elasticsearch](https://npm.io/package/@elastic/elasticsearch.md) — 2.1M weekly downloads
- [@c8y/client](https://npm.io/package/@c8y/client.md) — 15.3K weekly downloads
- [@signaldb/maverickjs](https://npm.io/package/@signaldb/maverickjs.md) — 1.7K weekly downloads
- [@bbc/http-transport-cache](https://npm.io/package/@bbc/http-transport-cache.md) — 1.2K weekly downloads

## Recent versions

- 1.0.0 (latest) — 2026-03-28
- 0.12.0 — 2023-07-28
- 0.11.0 — 2022-10-12
- 0.10.1 — 2022-03-10
- 0.10.0 — 2022-01-25
- 0.9.1 — 2021-01-13
- 0.9.0 — 2021-01-08
- 0.8.2 — 2020-09-15
- 0.8.1 — 2020-06-25
- 0.8.0 — 2020-06-25
- 0.7.0 — 2020-05-27
- 0.6.0 — 2020-04-21
- 0.5.0 — 2020-02-14
- 0.4.0 — 2020-02-02
- 0.3.0 — 2019-08-12
- … 4 more at https://npm.io/package/ky-universal/versions

## README

# ky-universal

> Use Ky in both Node.js and browsers

**This package is deprecated. Just use Ky directly. It runs natively on Node.js and in browsers.**

[Ky](https://github.com/sindresorhus/ky) is made for browsers, but this package makes it possible to use it in Node.js too, by polyfilling most of the required browser APIs using [`node-fetch`](https://github.com/bitinn/node-fetch).

This package can be useful for:
- Isomorphic code
- Web apps (React, Vue.js, etc.) that use server-side rendering (SSR)
- Testing browser libraries using a Node.js test runner

**Note:** Before opening an issue, make sure it's an issue with Ky and not its polyfills. Generally, if something works in the browser, but not in Node.js, it's an issue with `node-fetch`.

Keep in mind that Ky targets [modern browsers](https://github.com/sindresorhus/ky#browser-support) when used in the browser. For older browsers, you will need to transpile and use a [`fetch` polyfill](https://github.com/github/fetch).

## Install

```sh
npm install ky ky-universal
```

*Note that you also need to install `ky`.*

## Usage

```js
import ky from 'ky-universal';

const parsed = await ky('https://httpbin.org/json').json();

// …
```

## `ReadableStream` support

For [`ReadableStream`](https://developer.mozilla.org/en-US/docs/Web/API/ReadableStream) support, also install [`web-streams-polyfill`](https://github.com/MattiasBuelens/web-streams-polyfill):

```sh
npm install web-streams-polyfill
```

You can then use it normally:

```js
import ky from 'ky-universal';

const {body} = await ky('https://httpbin.org/bytes/16');
const {value} = await body.getReader().read();
const result = new TextDecoder('utf-8').decode(value);

// …
```

## API

The API is exactly the same as the [Ky API](https://github.com/sindresorhus/ky#api), including the [named exports](https://github.com/sindresorhus/ky#httperror).

## FAQ

#### How do I use this with a web app (React, Vue.js, etc.) that uses server-side rendering (SSR)?

Use it like you would use Ky:

```js
import ky from 'ky-universal';

const parsed = await ky('https://httpbin.org/json').json();

// …
```

Webpack will ensure the polyfills are only included and used when the app is rendered on the server-side.

#### How do I test a browser library that uses Ky in AVA?

Put the following in package.json:

```json
{
	"ava": {
		"require": [
			"ky-universal"
		]
	}
}
```

The library that uses Ky will now *just work* in AVA tests.

#### `clone()` hangs with a large response in Node - What should I do?

Streams in Node.js have a smaller internal buffer size (16 kB, aka `highWaterMark`) than browsers (>1 MB, not consistent across browsers). When using Ky, the default `highWaterMark` is set to 10 MB, so you shouldn't encounter many issues related to that.

However, you can specify a custom `highWaterMark` if needed:

```js
import ky from 'ky-universal';

const response = await ky('https://example.com', {
	// 20 MB
	highWaterMark: 1000 * 1000 * 20
});

const data = await response.clone().buffer();
```

## Related

- [ky](https://github.com/sindresorhus/ky) - Tiny and elegant HTTP client based on the browser Fetch API
- [got](https://github.com/sindresorhus/got) - Simplified HTTP requests in Node.js

---
_Source: https://npm.io/package/ky-universal · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
