Skip to content
A modern Apache Kafka client for node.js
JavaScript Other
Branch: master
Clone or download
Latest commit 8c5cadf Nov 18, 2019
Type Name Latest commit message Commit time
Failed to load latest commit information.
docs Update Oct 24, 2019
examples Fix examples Dec 7, 2018
logo Update to logo v2 and new colors Mar 26, 2019
scripts Reproduce #506 Sep 23, 2019
src Merge branch 'master' into pr/support-nodejs-12.x Nov 10, 2019
testHelpers Reproduce #506 Sep 23, 2019
types - add type boolean in ssl KafkaConfig Nov 18, 2019
website Update Docusaurus to 1.13.0 Sep 18, 2019
.eslintignore Use custom docker labels when running tests Sep 17, 2018
.eslintrc Expose new test function for kafka 1.1 Nov 27, 2018
.gitignore Ignore Java files May 8, 2019
.npmignore Add tests for the typescript definitions Jun 13, 2019
.prettierignore Update to logo v2 and new colors Mar 26, 2019
.prettierrc Add tests for the typescript definitions Jun 13, 2019 Bump version (v1.11.0) and update changelog Sep 30, 2019
LICENSE Revert "Update license year" Mar 27, 2019 Link to Schema Registry lib from readme Sep 13, 2019
azure-pipelines.yml Temporarily disable github releases for pre-releases Jul 26, 2019
docker-compose.0_10.yml Switch to official confluent Docker images Apr 27, 2019
docker-compose.1_1.yml Switch to official confluent Docker images Apr 27, 2019
docker-compose.2_2.yml Upgrade Kafka to 2.2.3 Sep 13, 2019
index.js Export partitioners and add JavaCompatiblePartitioner May 8, 2019
jest.config.js Update to latest jest Feb 4, 2019
logoV2.png Update to logo v2 and new colors Mar 26, 2019
package.json Bump version (v1.11.0) and update changelog Sep 30, 2019
yarn.lock Bump mixin-deep from 1.3.1 to 1.3.2 Sep 13, 2019


A modern Apache Kafka client for node.js. This library is compatible with Kafka 0.10+.
Native support for Kafka 0.11 features.

KafkaJS is battle-tested and ready for production.

Build Status npm version Slack Channel


  • Producer
  • Consumer groups with pause, resume, and seek
  • Transactional support for producers and consumers
  • Message headers
  • GZIP compression
  • Snappy and LZ4 compression through plugins
  • Plain, SSL and SASL_SSL implementations
  • Support for SCRAM-SHA-256 and SCRAM-SHA-512
  • Support for AWS IAM authentication
  • Admin client

Read something on the website that didn't work with the latest stable version?
Check the pre-release versions - the website is updated on every merge to master.

Getting Started

npm install kafkajs
# yarn add kafkajs
const { Kafka } = require('kafkajs')

const kafka = new Kafka({
  clientId: 'my-app',
  brokers: ['kafka1:9092', 'kafka2:9092']

const producer = kafka.producer()
const consumer = kafka.consumer({ groupId: 'test-group' })

const run = async () => {
  // Producing
  await producer.connect()
  await producer.send({
    topic: 'test-topic',
    messages: [
      { value: 'Hello KafkaJS user!' },

  // Consuming
  await consumer.connect()
  await consumer.subscribe({ topic: 'test-topic', fromBeginning: true })

    eachMessage: async ({ topic, partition, message }) => {
        offset: message.offset,
        value: message.value.toString(),



Learn more about using KafkaJS on the official site!


KafkaJS is an open-source project where development takes place in the open on GitHub. Although the project is maintained by a small group of dedicated volunteers, we are grateful to the community for bugfixes, feature development and other contributions.

See Developing KafkaJS for information on how to run and develop KafkaJS.

Help wanted 🤝

We welcome contributions to KafkaJS, but we also want to see a thriving third-party ecosystem. If you would like to create an open-source project that builds on top of KafkaJS, please get in touch and we'd be happy to provide feedback and support.

Here are some projects that we would like to build, but haven't yet been able to prioritize:


Thanks to Sebastian Norde for the V1 logo ❤️

Thanks to Tracy (Tan Yun) for the V2 logo ❤️

Sponsored by:


See LICENSE for more details.

You can’t perform that action at this time.