Installation
Requirements
- Node.js 18 or later
- A running Kafka broker (for integration)
Installing the Client
Install the core client package:
bash
pnpm add @kafkats/clientbash
npm install @kafkats/clientbash
yarn add @kafkats/clientInstalling Flow (Stream Processing)
For Kafka Streams-like processing, install the flow package:
bash
pnpm add @kafkats/flowbash
npm install @kafkats/flowbash
yarn add @kafkats/flowOptional Packages
Native CRC32C (Recommended)
For maximum producer/consumer throughput, install the optional native CRC32C implementation:
bash
pnpm add @node-rs/crc32bash
npm install @node-rs/crc32bash
yarn add @node-rs/crc32With native CRC32C enabled, kafkats can exceed the throughput of other popular Kafka clients.
If not installed, kafkats falls back to a pure TypeScript CRC32C implementation.
Zod Codec
For schema validation with Zod:
bash
pnpm add @kafkats/flow-codec-zod zodLMDB State Store
For persistent state in stream processing:
bash
pnpm add @kafkats/flow-state-lmdbNative Dependencies
The LMDB package includes native bindings. Make sure you have the necessary build tools installed on your system.
TypeScript Configuration
kafkats is written in TypeScript and includes type definitions. For the best experience, ensure your tsconfig.json includes:
json
{
"compilerOptions": {
"module": "ESNext",
"moduleResolution": "bundler",
"strict": true,
"esModuleInterop": true
}
}Verifying Installation
Create a simple test file to verify the installation:
typescript
import { KafkaClient } from '@kafkats/client'
const client = new KafkaClient({
clientId: 'test',
brokers: ['localhost:9092'],
})
console.log('kafkats installed successfully!')Run it:
bash
npx tsx test.ts