kafkajs-snappy-typescript provides a Snappy compression and decompression codec specifically designed for use with KafkaJS, offering strict TypeScript compatibility. This package serves as a type-safe alternative to `tulios/kafkajs-snappy`, aiming to integrate seamlessly into TypeScript-first KafkaJS applications. It leverages Brooooooklyn's `snappy` Node.js compression library for its core compression logic. The current stable version is 1.0.3, primarily consisting of bug fixes and rebundling efforts to ensure proper NPM publication. As a specialized codec, its release cadence is tied to necessary compatibility updates with KafkaJS or its underlying `snappy` dependency, rather than frequent feature additions. Its key differentiator is its explicit focus on strong typing for KafkaJS environments.
npm install kafkajs-snappy-typescriptVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates how to register the Snappy codec with KafkaJS and then use it to send and receive messages with Snappy compression.
Ensure the codec registration line is executed before any KafkaJS producer or consumer operations that involve Snappy compression.
Refer to the official `snappy` (Brooooooklyn/snappy) package's installation instructions and ensure all necessary system-level build tools (e.g., Python, C/C++ compiler) are installed and configured for `node-gyp`.
Choose one Snappy codec library for KafkaJS (either `kafkajs-snappy-typescript` or `kafkajs-snappy`) and stick with it throughout your project for consistency and to avoid potential conflicts.
Add `CompressionCodecs[CompressionTypes.Snappy] = new SnappyCodec().codec;` to your application startup code, ensuring it runs before KafkaJS operations.
Ensure you have the necessary build tools installed on your system. For `node-gyp`, this typically includes Python 3, `make` (or Xcode on macOS, Visual C++ Build Tools on Windows). Consult the `node-gyp` and `snappy` documentation for detailed prerequisites.
Ensure you are instantiating the class correctly: `new SnappyCodec().codec`. Also, verify the import path: `import { SnappyCodec } from 'kafkajs-snappy-typescript';`