{
 "kind": "tool",
 "slug": "undici",
 "path": "tools/undici/",
 "name": "undici",
 "maker": null,
 "density": "full",
 "crumbs": [
  [
   "Tools",
   "tools/"
  ],
  [
   "HTTP clients and networking",
   "tools/http-clients/"
  ]
 ],
 "lead": "The web request engine behind Node.js fetch.",
 "chips": [
  {
   "label": "HTTP clients and networking",
   "path": "tools/http-clients/"
  },
  {
   "label": "NPM"
  }
 ],
 "primary": {
  "label": "Copy install command",
  "copy": "npm install undici"
 },
 "links": [
  {
   "label": "GitHub",
   "href": "https://github.com/nodejs/undici"
  },
  {
   "label": "Website",
   "href": "https://undici.nodejs.org"
  }
 ],
 "track": "New versions, deprecation and license changes on your dashboard",
 "verdicts": [
  {
   "key": "license",
   "label": "License",
   "value": "MIT",
   "status": "yes",
   "sub": "Use it in paid apps",
   "quote": "Permission is hereby granted, free of charge, to any person obtaining a copy",
   "note": "Paid and closed-source products may use it; no fee and no on-screen credit needed.",
   "src": "https://github.com/nodejs/undici/blob/main/LICENSE"
  },
  {
   "key": "maint",
   "label": "Maintained",
   "value": "Maintained",
   "status": "yes",
   "sub": "Last change Nov 24, 2026",
   "note": "Latest GitHub release Nov 20, 2026. ",
   "src": "https://github.com/nodejs/undici"
  },
  {
   "key": "pop",
   "label": "Used by agents' projects",
   "value": "107 projects",
   "status": "info",
   "sub": "#9 of 126 in its category",
   "note": "Dependency in 107 public GitHub projects set up for AI coding agents that we scanned (1.7%).",
   "src": null
  },
  {
   "key": "agent",
   "label": "Agent access",
   "value": "Install only",
   "status": "info",
   "sub": null,
   "note": "Agent skills for this library in the skills catalog; community skills are written by others, read them before you install.",
   "src": null
  }
 ],
 "vfoot": "From the package registry and GitHub, checked daily; card checked Nov 10, 2026.",
 "blocks": [
  {
   "id": "overview",
   "nav": "Overview",
   "h2": "What undici does",
   "parts": [
    {
     "t": "prose",
     "text": "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."
    },
    {
     "t": "h3",
     "text": "What people build with it"
    },
    {
     "t": "uses",
     "items": [
      {
       "title": "Call outside services from your server",
       "text": "Your Node.js backend asks a weather, payment or AI service for data and reads the JSON answer, with less overhead than fetch().",
       "idea": false
      },
      {
       "title": "Send every fetch through a company proxy",
       "text": "On a work network, one setting makes all fetch() calls follow the usual proxy settings, while local addresses skip the proxy.",
       "idea": false
      },
      {
       "title": "Fake outside services in tests",
       "text": "Tests for code that calls other services get prepared answers instead of real network calls, so they run fast and offline.",
       "idea": false
      },
      {
       "title": "Retry when a service hiccups",
       "text": "When another service answers 503 or 429 or drops the connection, the request waits and tries again a few times.",
       "idea": false
      },
      {
       "title": "Cache answers that rarely change",
       "text": "Repeated requests for the same data are answered from memory while the other service says the data is still fresh.",
       "idea": false
      },
      {
       "title": "A newer fetch than your Node.js has",
       "text": "Get request fixes and features before your Node.js version ships them, without upgrading Node.js itself.",
       "idea": false
      }
     ]
    }
   ]
  },
  {
   "id": "popularity",
   "nav": "Popularity",
   "h2": "undici popularity",
   "parts": [
    {
     "t": "stats",
     "items": [
      {
       "n": "76",
       "of": "/ 100",
       "l": "Gid Score, #187 overall"
      },
      {
       "n": "355M",
       "l": "downloads a week, npm"
      },
      {
       "n": "7,762",
       "l": "GitHub stars"
      },
      {
       "n": "107",
       "l": "agent projects use it"
      }
     ]
    },
    {
     "t": "small",
     "text": "Gid Score measures public popularity and activity, not quality.",
     "link": "How the Gid Score is calculated",
     "path": "tools/top/"
    }
   ]
  },
  {
   "id": "usage",
   "nav": "How it is used",
   "h2": "How undici is used",
   "parts": [
    {
     "t": "list",
     "items": [
      "undici is a dependency in 107 of the 6,258 public GitHub projects set up for AI coding agents that we scanned (2.2% of the 4,867 JavaScript/TypeScript ones), #9 of 126 in http clients and networking.",
      "Counting the projects our scan samples by dependency (Solana 3,067, Ethereum and EVM 1,774, 3D and games 3,130, agent frameworks and SDKs 13,750), it appears in 363; those are left out of every share on this page.",
      "The most used alternative in our scan is Axios (470 projects).",
      "Projects that use it most often also use tsx (69.2%), Vitest (74.8%), Zod (80.4%).",
      "It is more common in projects set up for OpenClaw (11.7%) than for Cursor (0.9%)."
     ]
    },
    {
     "t": "h3",
     "text": "By coding agent"
    },
    {
     "t": "rows",
     "rows": [
      {
       "l": "80 projects, 2.4%",
       "v": "Claude Code",
       "path": "agents/claude-code/"
      },
      {
       "l": "58 projects, 1.9%",
       "v": "GitHub Copilot",
       "path": "agents/github-copilot/"
      },
      {
       "l": "39 projects, 11.7%",
       "v": "OpenClaw",
       "path": "agents/openclaw/"
      },
      {
       "l": "27 projects, 5.7%",
       "v": "Gemini CLI",
       "path": "agents/gemini-cli/"
      },
      {
       "l": "22 projects, 0.9%",
       "v": "Cursor",
       "path": "agents/cursor/"
      },
      {
       "l": "8 projects, 2.3%",
       "v": "OpenCode",
       "path": "agents/opencode/"
      },
      {
       "l": "8 projects, 1.7%",
       "v": "OpenAI Codex",
       "path": "agents/openai-codex/"
      }
     ]
    },
    {
     "t": "h3",
     "text": "Often used with"
    },
    {
     "t": "rows",
     "rows": [
      {
       "l": "In 69.2% of its projects",
       "v": "tsx",
       "path": "tools/tsx/"
      },
      {
       "l": "In 74.8% of its projects",
       "v": "Vitest",
       "path": "tools/vitest/"
      },
      {
       "l": "In 80.4% of its projects",
       "v": "Zod",
       "path": "tools/zod/"
      },
      {
       "l": "In 52.3% of its projects",
       "v": "ws",
       "path": "tools/ws/"
      },
      {
       "l": "In 56.1% of its projects",
       "v": "dotenv",
       "path": "tools/dotenv/"
      },
      {
       "l": "In 48.6% of its projects",
       "v": "Express",
       "path": "tools/express/"
      },
      {
       "l": "In 47.7% of its projects",
       "v": "chalk",
       "path": "tools/chalk/"
      },
      {
       "l": "In 43.9% of its projects",
       "v": "Model Context Protocol SDK (JavaScript)",
       "path": "tools/modelcontextprotocol/"
      }
     ]
    }
   ]
  },
  {
   "id": "more",
   "nav": null,
   "spy_as": "usage",
   "h2": "More about undici",
   "parts": [
    {
     "t": "more",
     "items": [
      {
       "title": "Funding",
       "path": "tools/funding/",
       "items": [
        "GitHub Sponsors: https://github.com/nodejs",
        "Open Collective: https://opencollective.com/nodejs",
        "57 GitHub sponsors"
       ]
      },
      {
       "title": "Head to head",
       "items": [
        {
         "text": "Axios vs undici",
         "note": "used together in 21 projects",
         "path": "tools/compare/axios-vs-undici/"
        }
       ]
      },
      {
       "title": "More in HTTP clients and networking",
       "path": "tools/http-clients/",
       "items": [
        {
         "text": "Requests",
         "path": "tools/requests-py/"
        },
        {
         "text": "httpx",
         "path": "tools/httpx/"
        },
        {
         "text": "ws",
         "path": "tools/ws/"
        },
        {
         "text": "postgres",
         "path": "tools/postgres/"
        },
        {
         "text": "aiohttp",
         "path": "tools/aiohttp/"
        },
        {
         "text": "websockets",
         "path": "tools/websockets/"
        },
        {
         "text": "redis (Python)",
         "path": "tools/redis-pypi/"
        },
        {
         "text": "node-fetch",
         "path": "tools/node-fetch/"
        }
       ]
      }
     ]
    }
   ]
  },
  {
   "id": "alternatives",
   "nav": "Alternatives",
   "h2": "Alternatives",
   "parts": [
    {
     "t": "alts",
     "items": [
      {
       "name": "undici",
       "me": true,
       "facts": [
        "MIT",
        "Gid 76",
        "355M/wk"
       ]
      },
      {
       "name": "Axios",
       "why": "Pick Axios when the same request code must run in the browser and in Node.js and you want interceptors.",
       "path": "tools/axios/",
       "facts": [
        "MIT",
        "Gid 91",
        "15M/wk"
       ]
      },
      {
       "name": "Got",
       "why": "Pick Got when you want a Node.js request library with retries, hooks and streams in one friendly interface.",
       "path": "tools/got/",
       "facts": []
      },
      {
       "name": "httpx",
       "why": "Pick httpx when your server is written in Python rather than Node.js.",
       "path": "tools/httpx/",
       "facts": []
      },
      {
       "name": "cross-fetch",
       "why": "Universal WHATWG Fetch API implementation for Node, browsers and React Native.",
       "path": "tools/cross-fetch/",
       "facts": [
        "MIT",
        "Gid 60",
        "53.9M/wk"
       ]
      }
     ],
     "more": "Compare undici with another tool",
     "more_path": "tools/compare/"
    }
   ]
  },
  {
   "id": "start",
   "nav": "Get started",
   "h2": "Get started",
   "parts": [
    {
     "t": "prompt",
     "text": "Use the npm package undici (pin undici@8.12.4, Node.js 22.19+) for server-side requests; always consume or dump the response body, and use EnvHttpProxyAgent with setGlobalDispatcher if we are behind a proxy."
    },
    {
     "t": "steps",
     "items": [
      {
       "text": "Add undici to your Node.js project (version 8 needs Node.js 22.19 or newer).",
       "code": "npm i undici",
       "src": "https://github.com/nodejs/undici/blob/main/README.md"
      },
      {
       "text": "Make a request and read the answer; always read or discard the body.",
       "code": "import { request } from 'undici'\nconst { statusCode, body } = await request('https://api.example.com/data');\nconst data = await body.json();\n",
       "src": "https://github.com/nodejs/undici/blob/main/README.md"
      }
     ]
    },
    {
     "t": "h3",
     "text": "Mistakes to avoid"
    },
    {
     "t": "mistakes",
     "items": [
      {
       "dont": "const { statusCode } = await request(url) and never touching body",
       "fix": "Read the body, or call await body.dump() when you only need the status or headers",
       "why": "Unread bodies keep connections busy; for request() reading the body is mandatory."
      },
      {
       "dont": "Passing { agent } from https-proxy-agent to fetch()",
       "fix": "fetch(url, { dispatcher: new ProxyAgent(proxyUrl) }) or setGlobalDispatcher(new EnvHttpProxyAgent())",
       "why": "undici and Node's fetch route requests through dispatchers, not through an agent option."
      },
      {
       "dont": "Mixing undici's fetch with the global FormData (or the other way round)",
       "fix": "Take fetch and FormData from the same place, or call install() from undici first",
       "why": "The two copies are different implementations and can break when mixed."
      },
      {
       "dont": "await body.json() followed by await body.text()",
       "fix": "const text = await body.text(); const data = JSON.parse(text)",
       "why": "A body can be consumed only once; the second call throws TypeError unusable."
      },
      {
       "dont": "Installing undici 8 on Node.js 20",
       "fix": "Upgrade to Node.js 22.19+ or pin undici 7.x",
       "why": "undici 8 declares Node.js 22.19.0 as its minimum."
      }
     ]
    }
   ]
  },
  {
   "id": "faq",
   "nav": "Questions",
   "h2": "Questions",
   "parts": [
    {
     "t": "faq",
     "items": [
      {
       "q": "Do I need it if Node.js already has fetch()?",
       "a": "Not for simple requests. Install it when you need proxies, test mocks, retries, connection tuning or a newer version than your Node.js bundles.",
       "evidence": {
        "url": "https://github.com/nodejs/undici/blob/main/README.md",
        "quote": "You need APIs not available in the built-in fetch (ProxyAgent, Socks5Agent, MockAgent, etc.)"
       }
      },
      {
       "q": "Does setGlobalDispatcher also change Node's built-in fetch?",
       "a": "Yes. The global dispatcher is shared with the copy of undici inside Node.js.",
       "evidence": {
        "url": "https://github.com/nodejs/undici/blob/main/README.md",
        "quote": "Global dispatcher is shared among compatible undici modules, including undici that is bundled internally with node.js."
       }
      },
      {
       "q": "Why do I get \"TypeError unusable\" after reading the body?",
       "a": "A body can be read only once; read it as text first if you need it twice, then parse the text.",
       "evidence": {
        "url": "https://github.com/nodejs/undici/blob/main/README.md",
        "quote": "Should you need to access the body in plain-text after using a mixin, the best practice is to use the .text() mixin first and then manually parse the text to the desired format."
       }
      },
      {
       "q": "Can it go through a SOCKS proxy?",
       "a": "Yes. ProxyAgent handles HTTP, HTTPS and SOCKS5 proxy addresses.",
       "evidence": {
        "url": "https://github.com/nodejs/undici/blob/main/docs/docs/api/ProxyAgent.md",
        "quote": "A ProxyAgent routes every request through an HTTP, HTTPS, or SOCKS5 proxy server."
       }
      },
      {
       "q": "Can I use it in a paid product?",
       "a": "Yes. It is MIT licensed; keep the license notice with its files.",
       "evidence": {
        "url": "https://github.com/nodejs/undici/blob/main/LICENSE",
        "quote": "Permission is hereby granted, free of charge, to any person obtaining a copy"
       }
      }
     ]
    }
   ]
  }
 ],
 "glance": [
  [
   "Package",
   "npm undici"
  ],
  [
   "Category",
   "HTTP clients and networking"
  ],
  [
   "License",
   "MIT"
  ],
  [
   "Gid Score",
   "75.6"
  ],
  [
   "Rank in category",
   "#9 of 126"
  ],
  [
   "GitHub",
   "nodejs/undici"
  ],
  [
   "Last change",
   "Nov 24, 2026"
  ]
 ],
 "good": [
  "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."
 ],
 "checked_line": "Read by AgentGid from 10 official pages, card checked Nov 10, 2026; numbers update daily.",
 "logo": "https://agentgid.com/media/avatars/nodejs.png"
}