undici downloads · last 12 months
Undici is a complete rewrite of Node.js's built-in HTTP/1.1 client, focusing on performance and a modern API. It addresses limitations in the native `http` and `https` modules, offering improved throughput and a more predictable developer experience for network requests. This package aims to provide a robust foundation for any application requiring efficient and reliable HTTP communication within the Node.js ecosystem.
The core philosophy behind Undici is to build a high-performance, spec-compliant HTTP client from the ground up. It targets Node.js developers who require fine-grained control over network operations and seek to minimize overhead. The design prioritizes efficiency, correctness, and a clear, composable API, making it suitable for both high-concurrency servers and demanding client-side applications.
Undici exposes a functional API, emphasizing stream-based processing and request/response pipelining. Key features include a `request` function for initiating HTTP requests, interceptors for modifying requests and responses globally, and a robust pool management system. It also provides `pipeline` for efficient multiplexing of requests over a single connection and `ProxyAgent` for handling proxy configurations seamlessly.
This client integrates well into various Node.js frameworks and tools. It can be used directly in plain Node.js applications, or within frameworks like Express.js or Fastify when making outgoing HTTP calls. Its stream-based nature also makes it compatible with asynchronous iteration patterns, fitting into modern JavaScript workflows that rely on `async/await` and generators.
With a weekly download count of 98.5 million, Undici demonstrates significant adoption and is actively maintained, as indicated by its last update in September 2026. Its unpacked size of 1.9 MB and gzipped bundle size of 168.3 kB are moderate for a comprehensive HTTP client, striking a balance between feature richness and footprint.
While Undici offers a powerful and efficient client, developers should be aware that its API differs from the legacy `http` module. Migrating existing codebases may require adjustments to how requests are initiated and responses are handled, particularly concerning error handling and stream management. It's essential to consult the documentation for proper integration and to leverage its full capabilities.
- When building Node.js applications that require efficient and high-throughput HTTP/1.1 client capabilities.
- For scenarios demanding fine-grained control over request/response streams and connection pooling.
- When needing to implement advanced HTTP features like request interception or response streaming.
- For integrating with microservices or external APIs where reliable and performant communication is critical.
- When leveraging asynchronous iteration patterns for processing large response bodies.
- For modernizing existing Node.js applications by replacing the legacy `http` or `https` modules with a more performant alternative.
- If your application's HTTP client needs are minimal and primarily involve simple GET requests without complex headers or bodies, the native `http` module might suffice.
- When a significantly smaller bundle size is an absolute requirement and the features of Undici are not fully utilized.
- If maintaining strict compatibility with older Node.js versions that do not support its API surface is a primary concern.
- For basic JSON-to-JSON API calls where simpler, more specialized libraries might offer a quicker setup.
- When the complexity of managing stream-based APIs and error handling in Undici outweighs the benefits for straightforward network interactions.
CORRECTIONS
Spot wrong data here?Spot wrong data on this page?
A short note helps us fix it.A short note helps us fix it. We read every one; confirmed fixes ship in the next nightly build.
Anonymous · No account · No email back