# @restorecommerce/kafka-client

> Opinionated Kafka Client for Microservices

Latest version **1.4.3** (published 2026-08-05) · MIT license · 0 weekly downloads

## Install

```sh
npm install @restorecommerce/kafka-client
pnpm add @restorecommerce/kafka-client
yarn add @restorecommerce/kafka-client
bun add @restorecommerce/kafka-client
```

## Health

**Score 70/100 (B)** — status: active.

Positive: has types; esm support; no vulnerabilities; recently updated; high maintenance score; high quality score.

Warnings: low downloads.

## Facts

| | |
|---|---|
| Version | 1.4.3 |
| Published | 2026-08-05 |
| First published | 2017-12-28 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Node | >= 12.0.0 |
| Dependencies | 9 |
| Unpacked size | 197.8 KB |
| Known vulnerabilities | 0 (+2 in 1 direct dependencies) |
| Install scripts | no |
| Author | n-fuse GmbH |
| Maintainers | vanthome, akumarnpm, dani723, vilsol, radu1990 |
| Keywords | restore, commerce, kafka, client |

## Links

- npm: https://www.npmjs.com/package/@restorecommerce/kafka-client
- Repository: https://github.com/restorecommerce/kafka-client
- npm.io page: https://npm.io/package/@restorecommerce/kafka-client

## Dependencies (9)

- [async](https://npm.io/package/async.md) 3.2.6
- [retry](https://npm.io/package/retry.md) 0.13.1
- [events](https://npm.io/package/events.md) 3.3.0
- [remeda](https://npm.io/package/remeda.md) 2.39.0
- [protobufjs](https://npm.io/package/protobufjs.md) 8.6.3
- [cls-rtracer](https://npm.io/package/cls-rtracer.md) 2.6.4
- [@platformatic/kafka](https://npm.io/package/@platformatic/kafka.md) 2.3.0
- [@restorecommerce/logger](https://npm.io/package/@restorecommerce/logger.md) ^1.4.3
- [@restorecommerce/rc-grpc-clients](https://npm.io/package/@restorecommerce/rc-grpc-clients.md) ^5.2.3

## Alternatives

- [launchdarkly-js-client-sdk](https://npm.io/package/launchdarkly-js-client-sdk.md) — 2.5M weekly downloads
- [@elastic/elasticsearch](https://npm.io/package/@elastic/elasticsearch.md) — 2.1M weekly downloads
- [@c8y/client](https://npm.io/package/@c8y/client.md) — 15.3K weekly downloads
- [@signaldb/maverickjs](https://npm.io/package/@signaldb/maverickjs.md) — 1.7K weekly downloads
- [@bbc/http-transport-cache](https://npm.io/package/@bbc/http-transport-cache.md) — 1.2K weekly downloads

## Recent versions

- 1.4.3 (latest) — 2026-08-05
- 1.4.2 — 2026-07-03
- 1.4.1 — 2026-06-16
- 1.4.0 — 2026-06-12
- 1.3.15 — 2026-05-27
- 1.3.14 — 2026-05-12
- 1.3.13 — 2026-05-11
- 1.3.12 — 2026-04-07
- 1.3.11 — 2026-03-31
- 1.3.10 — 2026-02-17
- 1.3.9 — 2026-02-16
- 1.3.8 — 2026-02-06
- 1.3.7 — 2025-11-11
- 1.3.6 — 2025-10-24
- 1.3.5 — 2025-10-16
- … 128 more at https://npm.io/package/@restorecommerce/kafka-client/versions

## README

# kafka-client

[![Version][version]](https://www.npmjs.com/package/@restorecommerce/kafka-client)[![Build Status][build]](https://travis-ci.org/restorecommerce/kafka-client?branch=master)[![Dependencies][depend]](https://david-dm.org/restorecommerce/kafka-client)[![Coverage Status][cover]](https://coveralls.io/github/restorecommerce/kafka-client?branch=master)

[version]: http://img.shields.io/npm/v/%40restorecommerce%2Fkafka%2Dclient.svg?style=flat-square
[build]: http://img.shields.io/travis/restorecommerce/kafka-client/master.svg?style=flat-square
[depend]: https://img.shields.io/david/restorecommerce/kafka-client.svg?style=flat-square
[cover]: http://img.shields.io/coveralls/restorecommerce/kafka-client/master.svg?style=flat-square


A Node.js client for [Apache Kafka](https://kafka.apache.org/) based on [kafka-node](https://github.com/SOHU-Co/kafka-node). 
Event messages structures are defined using [Protocol Buffers](https://developers.google.com/protocol-buffers) with message encoding/decoding being achieved using [protobufjs](https://github.com/dcodeIO/protobuf.js).

With this module, it is possible to have a fine grained control over which Kafka topics and event names the client can subscribe to. There could be multiple event names associated for the same message.
Internally message events are emitted to local listeners using [Node.js Events](https://nodejs.org/api/events.html), which decode protobuf messages and execute the intended listeners. 

This client includes a Provider object, which packages events and distributes them to the respective listeners. Currently, the following event providers are implemented:
- Kafka
- Local (in-process events, designed for testing)

When subscribing to a given event name, options can be passed. Currently, the supported subscription options are:
- `startingOffset` - value for the starting offset to process messages; default is `-1` (latest offset);
- `queue` - a boolean flag; if set to `true`, messages are queued and processed synchronously;
- `forceOffset` - a boolean flag; if set to `true`, `startingOffset` is considered above any other provided offset or configuration parameter.

## Development

### Tests

See [tests](test/). To execute the tests a set of _backing services_ are needed.
Refer to [System](https://github.com/restorecommerce/system) repository to start the backing-services before running the tests.

- To run tests

```sh
npm run test
```

## Usage

- Install dependencies

```sh
npm install
```

- Build

```sh
# compile the code
npm run build
```

---
_Source: https://npm.io/package/@restorecommerce/kafka-client · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
