KafkaJS

A modern Apache Kafka client for Node.js

Library
npm
v2.2.4
3,999 stars
MIT License

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum. How we score it →
51 /100 Fair
Development Activity 0
Maintenance 32
Community 72
Maturity 60
Momentum 40

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation. How we score it →
74 /100 Good
Architecture 80
Code Quality 75
Innovation 68
Learning Curve 72

KafkaJS is a Node.js client for Apache Kafka compatible with Kafka 0.10 and above, offering producers, consumer groups with pause/resume/seek, transactional messaging, and an admin client, all implemented natively in JavaScript with no dependency on librdkafka bindings.

It supports Plain, SSL, and SASL_SSL connections including SCRAM-SHA-256/512 and AWS IAM authentication, plus pluggable compression codecs (GZIP built-in, Snappy/LZ4/ZSTD via plugins). While actively used across the ecosystem and integrated into frameworks like NestJS, the upstream repository has seen no commits since mid-2024, so evaluate maintenance status against your production requirements.

What You Get

  • Native JavaScript Kafka client with no librdkafka/native binding dependency
  • Producer API with batching, compression, and idempotent/transactional writes
  • Consumer groups with pause, resume, and manual seek support
  • Admin client for topic/partition management and cluster metadata
  • SSL and SASL_SSL support including SCRAM-SHA-256/512 and AWS IAM authentication
  • Pluggable compression codecs (GZIP built-in; Snappy, LZ4, ZSTD via plugins)

Common Use Cases

  • Building event-driven microservices that produce/consume Kafka topics from Node.js
  • Implementing exactly-once processing pipelines using transactional producers/consumers
  • Connecting to managed Kafka (Confluent Cloud, AWS MSK) via SASL/IAM authentication
  • Building admin tooling to manage topics, partitions, and consumer group offsets
  • Integrating Kafka messaging into NestJS or Express-based services

Under The Hood

Architecture - src/cluster maintains broker metadata and connection pooling, src/broker implements the low-level Kafka wire protocol request/response cycle, src/consumer layers consumer-group coordination (join/sync/heartbeat, partition assignment, offset commits) on top of that, src/producer handles batching and idempotent/transactional writes, and src/admin exposes cluster/topic management - all connected through an src/instrumentation event bus that powers KafkaJS’s built-in logging and metrics hooks.

Tech Stack - Plain JavaScript (no TypeScript source, though types/ ships hand-written .d.ts definitions), zero required native dependencies - compression codecs like Snappy/LZ4/ZSTD are optional peer packages - and the repo ships Docker Compose files for Kafka versions 0.10 through 2.4 to test protocol compatibility across a broad version matrix.

Code Quality - Jest-based test suite (jest.config.js, *.spec.js files colocated with source, e.g. src/index.spec.js) with snapshot tests and a testHelpers directory for spinning up integration tests against real brokers via docker-compose; the project has 3,097 total commits and 144 contributors historically, but has had no commits since August 2024, so newly-opened issues/PRs are not being actively triaged.

API Design - The API centers on kafka.producer() / kafka.consumer({groupId}) factories returning promise-based objects with a small, consistent method surface (send, subscribe, run), and the instrumentation event bus lets consumers hook into internal events (e.g. REQUEST, CONNECT) for logging/metrics without modifying core behavior - a well-regarded design that contributed to its popularity even as maintenance has slowed.

Join founders buildingwith open source

Opinionated takes, migration guides, cost-saving tips, and insights from the open source ecosystem.

Subscribe on Substack
Join 750+ subscribers