KafkaJS is a modern Apache Kafka client library for Node.js, currently at stable version 2.2.4. It offers comprehensive features for producing and consuming messages, as well as administrative tasks, providing native support for Kafka 0.10+ and specifically 0.11 features like transactions and custom authentication mechanisms. The library ships with full TypeScript definitions, ensuring a robust development experience. It aims for a low-level, high-performance approach, with a relatively frequent release cadence for bug fixes and minor enhancements, as seen by multiple patch releases in quick succession after major version bumps. A key differentiator is its focus on Node.js specifics and robust error handling to prevent common issues like CPU spikes.
npm install kafkajsVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates how to initialize a Kafka client, send messages using a producer, and consume messages using a consumer, including basic error handling and graceful shutdown.
Thoroughly read the official v2.0.0 migration guide (https://kafka.js.org/docs/migration-guide-v2.0.0) before upgrading. Pay special attention to partitioner configuration and Node.js version requirements.
Upgrade to KafkaJS v2.1.0 or newer to resolve the issue of excessive CPU usage during prolonged broker unavailability.
Upgrade to KafkaJS v2.2.3 or newer to fix the SASL/PLAIN authentication regression.
Ensure you are using KafkaJS v2.2.4 or newer to mitigate issues with consumers getting stuck after throttling events.
Upgrade to KafkaJS v2.2.4 or newer to prevent infinite crash loops when no brokers are available, improving client resilience.
Ensure each logical consumer group (e.g., for different applications or environments) uses a unique `groupId`. Describe your consumer group to verify expected members.
Upgrade KafkaJS to v2.2.4 or newer to fix the consumer group rejoining logic after `ILLEGAL_GENERATION` errors.
Upgrade KafkaJS to v2.1.0 or newer to resolve the 100% CPU utilization issue during broker unavailability.
Upgrade KafkaJS to v2.2.3 or newer to fix the regression in SASL/PLAIN authentication.
Upgrade KafkaJS to v2.1.0 or newer to fix persistent errors when producing after a topic authorization error.
No dependency data recorded yet.