Extend your events across processes, threads, and machines. Demitter brings the familiar Node.js event API (via emittery) API to distributed systems, enabling real-time event communication between multiple Node.js processes with near-zero configuration.
Live auction system with multiple bidders across separate terminal processes - all synchronized in real-time
- 🚀 Distributed Events: Emit events across processes, threads, or machines
- ⚡ Zero Configuration: Works out of the box with sensible defaults
- 🎯 Familiar API: Extends the battle-tested sindresorhus/emittery library
- 🛡️ Type Safe: Full TypeScript support
- 📦 Lightweight: Efficient binary serialization with minimal overhead
- 🔧 Flexible: Embedded or standalone message proxy/forwarder deployment options
Get distributed events running in 3 steps:
That's it! Events emitted in one process are automatically received by all other connected processes.
Demitter extends the powerful emittery API with distributed capabilities. All emittery methods work exactly the same:
📖 Full API Documentation: See the complete emittery API docs for all available methods, TypeScript usage, and advanced features.
Creates a new distributed emitter instance.
Creates and starts a message forwarder to enable event distribution.
Closes the distributed emitter and cleans up connections.
- distributed:error: Emitted when distributed operations fail (network issues, serialization errors, etc.)
- Microservices Communication: Event-driven architecture between services
- Multi-Process Applications: Coordinate events across worker processes
- Real-Time Systems: Live updates, notifications, and state synchronization
- Distributed Logging: Centralized event collection from multiple sources
- Game Development: Real-time multiplayer game state management
- IoT Networks: Device communication and sensor data distribution
Explore practical examples in the examples/ directory:
- basic-usage.ts - Simple distributed events setup
- error-handling.ts - Robust error handling patterns
- live_auction/ - Complete live auction system demo
- Multi-process auction with bidders, controller, and spectator dashboard
- Real-time terminal UIs with charts and analytics
- Intelligent bidding strategies and conflict resolution
Start the forwarder within your application:
Run the forwarder as a separate service:
The system consists of two main components:
- Pub/Sub Forwarder - A standalone message broker that forwards events between distributed processes
- DistributedEmitter - An extension of Emittery class in the emittery library for distributed event emission
The forwarder acts as a central message broker using ZeroMQ's XSUB-XPUB proxy pattern.
After installing the package globally:
You can run the forwarder from anywhere:
For projects with demitter as a dependency:
The forwarder can be configured using environment variables:
| XSUB_PORT | 5555 | Port for XSUB socket (receives from publishers) |
| XPUB_PORT | 5556 | Port for XPUB socket (sends to subscribers) |
| XSUB_ADDRESS | tcp://*:${XSUB_PORT} | Full address for XSUB socket |
| XPUB_ADDRESS | tcp://*:${XPUB_PORT} | Full address for XPUB socket |
| LOG_LEVEL | info | Logging level (debug, info, warn, error) |
See LICENSE file.
I'm open to contributions but the details for contributions are not yet finalized. If you have ideas or improvements, feel free to open an issue or start a discussion before you raise a pull request.
.png)



