# undici — card for AI agents

High-performance HTTP/1.1 client for Node.js and Deno.

Category: HTTP clients and networking · npm package `undici` · latest version 8.12.3 (checked 2026-11-01)
Install: `npm install undici`
License: MIT (permissive)

In your own product (generator, app, hosted service): **yes**. Permissive license: ship it inside your own product, closed or open source, and keep its license and copyright notice.

## Numbers (AgentGid data)
- Gid Score: 75.6 (#187 of all tools, 13 of 126 in its category)
- Used in 107 public projects set up for AI coding agents (1.7%)
- Downloads last week: 355,342,579 (as of 2026-11-24), +57.2% over 4 weeks
- GitHub stars: 7,762 (as of 2026-11-24)
- Last push: 2026-11-24

## Often used with
tsx 69.2%, Vitest 74.8%, Zod 80.4%, ws 52.3%, dotenv 56.1%, Express 48.6%

## Checked alternatives (same job)
- Axios: https://agentgid.com/tools/axios/agent.md
- cross-fetch: https://agentgid.com/tools/cross-fetch/agent.md

## Links
- AgentGid page: https://agentgid.com/tools/undici/
- Homepage: https://undici.nodejs.org
- Repository: https://github.com/nodejs/undici


## undici: the web request engine behind Node.js fetch

undici is the free JavaScript package that makes web requests from Node.js servers; Node's own fetch() runs on a copy of it. Installing it yourself gives your app the newest version plus extras such as proxies, retries, caching and fake answers for tests. It does not run in the browser.

### Where to use it
- Call outside services from your server: Your Node.js backend asks a weather, payment or AI service for data and reads the JSON answer, with less overhead than fetch().
- Send every fetch through a company proxy: On a work network, one setting makes all fetch() calls follow the usual proxy settings, while local addresses skip the proxy.
- Fake outside services in tests: Tests for code that calls other services get prepared answers instead of real network calls, so they run fast and offline.
- Retry when a service hiccups: When another service answers 503 or 429 or drops the connection, the request waits and tries again a few times.
- Cache answers that rarely change: Repeated requests for the same data are answered from memory while the other service says the data is still fresh.
- A newer fetch than your Node.js has: Get request fixes and features before your Node.js version ships them, without upgrading Node.js itself.

### How to start
- Add undici to your Node.js project (version 8 needs Node.js 22.19 or newer).

```
npm i undici
```

- Make a request and read the answer; always read or discard the body.

```
import { request } from 'undici'
const { statusCode, body } = await request('https://api.example.com/data');
const data = await body.json();
```


### License
Free to use, also in paid and closed-source products, under the MIT license. Keep the copyright and license notice when you pass its files on.

### Good to know
- Version 8 needs Node.js 22.19 or newer; version 7 runs on Node.js 20.18.1 and newer.
- Always read or cancel each answer's body; leaving it unread can tie up connections and stall the app.
- Reading a whole answer at once loads it all into memory; for answers from unknown sources, read it piece by piece with a size limit.
- It is a Node.js package; for code that must also run in the browser, the built-in fetch() is the simpler choice.
- It is part of the Node.js project and actively released; 8.12.4 came out on 2026-11-05, and the 8.x line has support planned until 2029-04-30.

Checked 2026-11-10 against: https://undici.nodejs.org, https://github.com/nodejs/undici/blob/main/README.md, https://github.com/nodejs/undici/blob/main/LICENSE, https://github.com/nodejs/undici/blob/main/docs/docs/api/ProxyAgent.md, https://github.com/nodejs/undici/blob/main/docs/docs/api/EnvHttpProxyAgent.md, https://github.com/nodejs/undici/blob/main/docs/docs/api/MockAgent.md, https://github.com/nodejs/undici/blob/main/docs/docs/api/RetryAgent.md, https://github.com/nodejs/undici/blob/main/docs/docs/api/Agent.md, https://registry.npmjs.org/undici, https://registry.npmjs.org/undici/8.12.4

### Mistakes to avoid
- Don't: const { statusCode } = await request(url) and never touching body → Do: Read the body, or call await body.dump() when you only need the status or headers (Unread bodies keep connections busy; for request() reading the body is mandatory.)
- Don't: Passing { agent } from https-proxy-agent to fetch() → Do: fetch(url, { dispatcher: new ProxyAgent(proxyUrl) }) or setGlobalDispatcher(new EnvHttpProxyAgent()) (undici and Node's fetch route requests through dispatchers, not through an agent option.)
- Don't: Mixing undici's fetch with the global FormData (or the other way round) → Do: Take fetch and FormData from the same place, or call install() from undici first (The two copies are different implementations and can break when mixed.)
- Don't: await body.json() followed by await body.text() → Do: const text = await body.text(); const data = JSON.parse(text) (A body can be consumed only once; the second call throws TypeError unusable.)
- Don't: Installing undici 8 on Node.js 20 → Do: Upgrade to Node.js 22.19+ or pin undici 7.x (undici 8 declares Node.js 22.19.0 as its minimum.)

### Questions
- Do I need it if Node.js already has fetch()? Not for simple requests. Install it when you need proxies, test mocks, retries, connection tuning or a newer version than your Node.js bundles.
- Does setGlobalDispatcher also change Node's built-in fetch? Yes. The global dispatcher is shared with the copy of undici inside Node.js.
- Why do I get "TypeError unusable" after reading the body? A body can be read only once; read it as text first if you need it twice, then parse the text.
- Can it go through a SOCKS proxy? Yes. ProxyAgent handles HTTP, HTTPS and SOCKS5 proxy addresses.
- Can I use it in a paid product? Yes. It is MIT licensed; keep the license notice with its files.

---
AgentGid's catalog is curated: every entry was checked against the maker's official pages (registry, repository, license and pricing pages) on the date shown; a license value shows the quote it stands on wherever AgentGid has one. Usage numbers come from AgentGid's own scan of public repositories set up for AI coding agents. Claims by makers are reported, not tested by AgentGid.
