A modern Apache Kafka client for node.js
KafkaJS is a robust and modern Apache Kafka client designed specifically for Node.js, offering a streamlined approach to integrating Kafka into your applications. It is particularly noted for its ease of use and comprehensive support for Kafka features, making it an ideal choice for developers looking to leverage Kafka's capabilities for real-time data streaming and processing. KafkaJS supports various Kafka features such as consumer groups, custom partition assignment, and transactional messages, enhancing the reliability and scalability of applications. The package's commitment to simplicity and high performance makes it a preferred tool for Node.js developers working with Kafka.
To start using KafkaJS in your Node.js application, you can simply run `npm install kafkajs`. This command integrates KafkaJS seamlessly, allowing developers to quickly set up and start interacting with Kafka clusters. The package is well-documented, making it accessible to both beginners and experienced developers who wish to implement Kafka functionalities. KafkaJS also emphasizes security and robustness, offering features like SSL/TLS encryption and SASL authentication to ensure secure data transmission. By choosing KafkaJS, developers benefit from a modern, efficient, and secure Kafka client that is tailored to the unique demands of contemporary application development.
KafkaJS not only simplifies working with Kafka in Node.js but also ensures that applications are scalable and maintain high performance under varying loads. Its lightweight nature minimizes the overhead on your Node.js applications, ensuring efficient data handling and processing. The package's active community and ongoing updates contribute to a reliable and future-proof toolset that keeps pace with the evolving landscape of Kafka and real-time data streaming technologies.
Core dependencies of this npm package and its dev dependencies.
undefined@types/jest, @types/node, @typescript-eslint/typescript-estree, eslint, eslint-config-prettier, eslint-config-standard, eslint-plugin-import, eslint-plugin-jest, eslint-plugin-node, eslint-plugin-prettier, eslint-plugin-promise, eslint-plugin-standard, execa, glob, husky, ip, jest, jest-circus, jest-extended, jest-junit, jsonwebtoken, lint-staged, mockdate, prettier, semver, typescript, uuid
A README file for the kafkajs code repository. View Code
A modern Apache Kafka® client for Node.js
Get Started »
Read the Docs
·
Report Bug
·
Request Feature
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.
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 })
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.
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.
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:
See LICENSE for more details.
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.