Skip to content
CountlyPublic

About

No description, website, or topics provided.

Resources

Contributing

Security policy

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

4,622 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

@countly/kafkajs

A pure-JavaScript Apache Kafka client for Node.js, maintained by Countly as a standalone continuation of KafkaJS 2.2.4.

  • Drop-in for KafkaJS users: preserved API plus documented semantic differences. eachMessage/eachBatch, pause/resume, instrumentation events and error classes remain available; see the migration guide.
  • Targets current infrastructure: Apache Kafka 4.0–4.4 (KRaft) and Node.js 22+. Older brokers and runtimes are not supported.
  • Zero required runtime dependencies (one optional native dependency, lz4-napi, enables LZ4 compression), CommonJS entry point plus an ES module entry.

Status: under active development, not yet released. The first public version will be 3.0.0. Until then the package is not published to npm and internal pre-release tags (3.0.0-alpha.N) are used.

Features

  • Producer, with idempotent and transactional modes
  • Consumer groups with pause, resume and seek
  • Message headers
  • GZIP, Snappy, LZ4 and ZSTD compression built in (LZ4 needs the optional lz4-napi dependency); registered codecs take precedence
  • PLAINTEXT, SSL and SASL_SSL connections
  • SASL PLAIN, SCRAM-SHA-256, SCRAM-SHA-512, OAUTHBEARER, AWS IAM and GSSAPI (optional kerberos peer)
  • OAuth bearer token helpers and recipes (OAuth.md)
  • Admin client, including describeShareGroups, listShareGroupOffsets, alterShareGroupOffsets and deleteShareGroupOffsets for Kafka 4.2+; share-group deletion uses deleteGroups
  • Share groups (Kafka 4.2+) with compact acknowledgement outcomes, offset-reset recipes and explicit API boundaries.
  • Opt-in broker client telemetry with independent per-client IDs and bounded numeric snapshots.

Getting started

npm install @countly/kafkajs

Release candidates are published on the next dist-tag. Until 3.0.0, latest also points at a release candidate. Install release candidates by exact version.

const { Kafka } = require('@countly/kafkajs')
// or: import { Kafka } from '@countly/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 () => {
  await producer.connect()
  await producer.send({
    topic: 'test-topic',
    messages: [{ value: 'Hello Kafka user!' }],
  })

  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)

Documentation lives in the docs/ folder of this repository: Getting Started · Configuration · Producing · Consuming · Admin · Instrumentation events · Transactions.

Compression is selected per send() or sendBatch() call; there is no producer-level default. An omitted codec sends uncompressed, and setting a codec on one send does not change later sends. See compression.

On Kafka 4.4 or newer, admin.unregisterController({ controllerId }) removes a controller registration, and metadataClusterCheck controls whether reconnects name the expected cluster and node.

bootstrapResolveTimeout optionally waits for bootstrap DNS readiness before the first connection.

Migrating from kafkajs

Replace the package name for the preserved API plus documented semantic differences. Read the migration guide for the changed defaults and behavior, and the CHANGELOG for release details.

Contributing

See CONTRIBUTING.md and docs/DevelopmentEnvironment.md. Bugs and feature requests go to the issue tracker. Security reports: see SECURITY.md.

License

MIT. See LICENSE.

This project is a fork of KafkaJS, copyright (c) 2018 Túlio Ornelas and the KafkaJS contributors, used under the MIT license. Countly's changes are copyright (c) 2026 Countly and released under the same license. KafkaJS's name, logo and website belong to the original project; this fork does not use the KafkaJS logo and is not affiliated with or endorsed by the KafkaJS maintainers.

Apache Kafka and Kafka are trademarks of The Apache Software Foundation. This project is not affiliated with or endorsed by the Apache Software Foundation.

About

No description, website, or topics provided.

Resources

Contributing

Security policy

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages