undici

v8.0.2 MIT

An HTTP/1.1 client, written from scratch for Node.js

Weekly Downloads
55.7M
Stars
7.5K
Forks
743
Open Issues
328
Gzip Size
172.1 kB
Unpacked Size
1.6 MB
Dependencies
1
Last Updated
1mo ago

undici Download Trends

Download trends for undici071.8M143.7M215.5M287.4MFeb 2025MayAugNovFebApr 2026
undici

About undici

Undici is a modern, high-performance HTTP/1.1 client meticulously crafted from the ground up for Node.js. It aims to provide a robust and efficient alternative to Node.js's built-in 'http' and 'https' modules, addressing common performance bottlenecks and API complexities.

The core philosophy behind Undici is to offer a more performant, predictable, and developer-friendly HTTP client experience. It is designed for Node.js environments seeking to optimize network I/O, reduce latency, and simplify the management of HTTP requests and responses. Its primary audience includes backend developers building APIs, microservices, or applications that require frequent and efficient communication over HTTP.

Key API patterns in Undici revolve around a request/response stream-based model, prioritizing efficiency and control. It exposes methods like `request` and `request.stream`, along with comprehensive options for customizing headers, connection pooling, and error handling. Undici also integrates well with Node.js Streams API, allowing for seamless data piping and manipulation.

Undici seamlessly integrates into various Node.js workflows and frameworks. It can be used directly within server-side applications, build tools, or any Node.js process that needs to make outbound HTTP requests. Its design makes it a suitable drop-in replacement for the native `http` client in many scenarios, requiring minimal code changes.

With a reported unpacked size of 1.6 MB and a gzipped bundle size of 172.1 kB, Undici represents a significant client library. While not the smallest option, its engineering focuses on delivering considerable performance gains, especially in high-throughput scenarios. Its active development and broad adoption, evidenced by its 68.0M weekly downloads, indicate a mature and stable project.

Developers should be aware that migrating from Node.js's native `http` module might require adjustments due to Undici's distinct API and internal behavior, particularly concerning error handling and stream management. While it offers advanced features, understanding its underlying stream and pool mechanics is crucial for optimal utilization and debugging.

When to use

  • When building Node.js backend services that require efficient handling of numerous concurrent HTTP requests.
  • When optimizing the performance of API clients that frequently interact with external services.
  • When needing fine-grained control over HTTP request options, including connection pooling and keep-alive settings.
  • When leveraging Node.js Streams API for efficient request body uploads or response data processing.
  • When replacing Node.js's native `http` or `https` client for improved throughput and reduced latency.
  • When integrating background tasks or CLI tools that must reliably fetch data from web APIs.

When NOT to use

  • If your application's HTTP communication needs are exceptionally simple and do not benefit from advanced pooling or performance features; Node.js's built-in modules may suffice.
  • If shipping the absolute minimum bundle size is a critical constraint and HTTP client functionality is not a primary concern; consider lighter, more specialized libraries.
  • If you require automatic request retries, complex circuit breaking patterns, or sophisticated request queuing built directly into the client; these features might necessitate additional libraries or custom implementation.
  • When working within environments that strictly disallow third-party dependencies and require the use of only core Node.js modules.
  • If your primary need is for a WebSocket client; Undici is focused on HTTP/1.1 and does not natively provide WebSocket support.

undici Alternatives

undici Categories