mitt
Tiny (~200 byte) functional event emitter / pub-sub library for JavaScript. Mitt provides emit, on, and off methods for typed event handling in both browser and Node.js. No classes, no inheritance — just a factory function. Popular in Preact, Vue, and micro-frontends where event-bus patterns connect decoupled components without framework state management.
Score Breakdown
⚙ Agent Friendliness
🔒 Security
200 byte library with zero dependencies — minimal attack surface. Event payloads are in-memory only — no persistence or external transmission.
⚡ Reliability
Best When
You need a tiny, typed, dependency-free event emitter for simple pub-sub in JavaScript apps without framework overhead.
Avoid When
You need wildcards, namespacing, once() support, ordered handlers, or error propagation — use a fuller EventEmitter implementation.
Use Cases
- • Implement lightweight pub-sub event bus for agent micro-frontends that need decoupled component communication without Redux/Vuex overhead
- • Add typed event emitters to agent modules using mitt's TypeScript generic types for safe event payload typing
- • Create cross-frame or cross-component event communication in agent UIs where a shared event bus replaces prop drilling
- • Build simple agent workflow event notification systems where tasks emit events and multiple handlers subscribe to state changes
- • Replace Node.js EventEmitter with mitt for browser-compatible, typed event emission in isomorphic agent libraries
Not For
- • Complex event systems with ordering guarantees, priorities, or middleware — use EventEmitter3 or RxJS for more features
- • Distributed event streaming — mitt is in-process only; use NATS, Kafka, or Redis pub-sub for distributed events
- • Framework-idiomatic event handling — use Vue's $emit, React's callback props, or Angular EventEmitter for framework-native patterns
Interface
Authentication
No authentication — tiny local pub-sub library.
Pricing
mitt is open source and free.
Agent Metadata
Known Gotchas
- ⚠ mitt has no 'once()' handler — implement once() manually with a wrapper that calls off() after first invocation, or use mitt + a wrapper
- ⚠ Emitting events with no listeners is silently ignored — no error, no warning; typos in event names cause silent no-ops
- ⚠ mitt all events ('*') handler receives all events — useful for debugging but don't use in production if handlers have performance overhead
- ⚠ TypeScript event map must be defined upfront — mitt<Events>() where Events = {eventName: payload} provides type safety but requires planning all events at creation
- ⚠ Multiple mitt instances are independent — events emitted on one instance don't propagate to another; use a singleton for cross-module communication
- ⚠ No built-in error handling in handlers — exceptions in event handlers propagate up to emit() caller; wrap handlers in try/catch for resilient event systems
Alternatives
Full Evaluation Report
Detailed scoring breakdown, competitive positioning, security analysis, and improvement recommendations for mitt.
Scores are editorial opinions as of 2026-03-06.