A modern Apache Kafka client for node.js
  • JavaScript 98.3%
  • Shell 0.9%
  • TypeScript 0.6%
  • Java 0.1%
  • CSS 0.1%
Find a file
2024-05-16 08:27:05 +02:00
.github Add workflow for combining PRs 2022-03-09 09:05:15 +01:00
docs Clarity wording around compression codecs 2023-02-27 13:19:58 +01:00
examples Math.random with arguments? 2020-10-19 19:42:25 +02:00
logo Remove sponsorships 2024-05-16 08:12:14 +02:00
scripts Log the amount of memory used when running tests 2020-09-15 16:05:30 +02:00
src Fix test name 2023-02-27 13:34:45 +01:00
testHelpers Merge branch 'master' of github.com:tulios/kafkajs into lint-disallow-focused-tests 2022-05-02 15:09:08 +02:00
types fix saslAuthenticate parameter type definitions 2022-10-13 17:32:40 +11:00
website Versioned docs for 2.2.4 2023-02-27 14:24:19 +01:00
.eslintignore Use custom docker labels when running tests 2018-09-17 21:38:26 +02:00
.eslintrc Lint tests 2022-02-07 15:19:04 +01:00
.gitignore fixed gitignore jsconfig.js -> jsconfig.json 2021-03-28 16:52:26 +01:00
.npmignore Add issue templates 2020-04-21 09:13:13 +02:00
.prettierignore Update to logo v2 and new colors 2019-03-26 15:42:19 +01:00
.prettierrc Add tests for the typescript definitions 2019-06-13 11:40:01 +02:00
azure-pipelines.yml Remove support for EoL Node versions 10 and 12 2022-05-02 08:18:39 +02:00
CHANGELOG.md Bump version (v2.2.4) and update changelog 2023-02-27 13:59:21 +01:00
CONTRIBUTING.md Replace slackin with invite link 2022-08-26 08:44:38 +02:00
docker-compose.0_10.yml Respect default num partitions configuration when creating topics 2022-03-08 17:56:59 +01:00
docker-compose.0_11.yml Respect default num partitions configuration when creating topics 2022-03-08 17:56:59 +01:00
docker-compose.1_1.yml Respect default num partitions configuration when creating topics 2022-03-08 17:56:59 +01:00
docker-compose.2_2.yml Respect default num partitions configuration when creating topics 2022-03-08 17:56:59 +01:00
docker-compose.2_3.yml Respect default num partitions configuration when creating topics 2022-03-08 17:56:59 +01:00
docker-compose.2_4.yml Respect default num partitions configuration when creating topics 2022-03-08 17:56:59 +01:00
docker-compose.2_4_oauthbearer.yml Respect default num partitions configuration when creating topics 2022-03-08 17:56:59 +01:00
index.js Remove deprecated enum ResourceTypes 2022-05-02 08:34:22 +02:00
jest.config.js Do not bail on the first test failure 2020-03-19 11:53:20 +01:00
LICENSE Revert "Update license year" 2019-03-27 13:49:42 +01:00
logoV2.png Update to logo v2 and new colors 2019-03-26 15:42:19 +01:00
package.json Bump version (v2.2.4) and update changelog 2023-02-27 13:59:21 +01:00
README.md Remove sponsorships 2024-05-16 08:12:14 +02:00
yarn.lock Bump minimatch from 3.0.4 to 3.1.2 2023-02-27 12:41:19 +00:00

npm version npm pre-release version Build Status Slack Channel

Logo

KafkaJS

A modern Apache Kafka® client for Node.js
Get Started »

Read the Docs · Report Bug · Request Feature

Table of Contents

About the Project

KafkaJS is a modern Apache Kafka client for Node.js. It is compatible with Kafka 0.10+ and offers native support for 0.11 features.

KAFKA is a registered trademark of The Apache Software Foundation and has been licensed for use by KafkaJS. KafkaJS has no affiliation with and is not endorsed by The Apache Software Foundation.

Features

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

Getting Started

npm install kafkajs
# yarn add kafkajs

Usage

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 })

  await consumer.run({
    eachMessage: async ({ topic, partition, message }) => {
      console.log({
        partition,
        offset: message.offset,
        value: message.value.toString(),
      })
    },
  })
}

run().catch(console.error)

Learn more about using KafkaJS on the official site!

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.

Contributing

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 bug fixes, 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:

Contact 💬

Join our Slack community

License

See LICENSE for more details.

Acknowledgements

Apache Kafka and Kafka are either registered trademarks or trademarks of The Apache Software Foundation in the United States and other countries. KafkaJS has no affiliation with the Apache Software Foundation.