mitt
Tiny (~200 byte) functional event emitter and pubsub for JavaScript and TypeScript
Repository Health
Technical Analysis
mitt is an extremely small functional event emitter/pubsub library, weighing under 200 bytes gzipped, that gives JavaScript applications a familiar on/off/emit API modeled after Node’s EventEmitter. Unlike class-based emitters, mitt’s methods are purely functional and don’t rely on this, and it adds a wildcard '*' event type that listens to every emitted event.
Written in TypeScript, mitt provides strong generic typing for event maps when strict mode is enabled in a consuming project’s tsconfig.json, letting handlers infer their event payload types automatically. It has no dependencies, supports IE9+, and works in any JavaScript runtime, making it a common choice for decoupled component communication in frameworks like Vue and Preact as well as vanilla JavaScript applications.
What You Get
- A functional
on/off/emitevent emitter API modeled after Node’sEventEmitter, with no reliance onthis - A wildcard
'*'event type that listens to every emitted event, receiving both the event type and payload - Strong TypeScript generics — define an
Eventstype map and get inferred, type-checked handler and payload types - Direct access to the underlying
allMap of event names to handler sets, for bulk operations like clearing all listeners - Zero dependencies and IE9+ support, usable in any JavaScript runtime (browser, Node.js, or bundled via ESM/CJS/UMD)
Common Use Cases
- Decoupled communication between components in frameworks without a built-in event bus (e.g. Preact, Vue 3 which dropped its own
$on/$off) - Implementing a lightweight application-wide event bus for cross-cutting concerns like analytics or notifications
- Building small state or plugin systems that need publish/subscribe semantics without pulling in a full framework
- Prototyping or teaching event-driven patterns where a minimal, readable emitter implementation is preferred over Node’s built-in EventEmitter in browser code
Under The Hood
Architecture - mitt is implemented as a single ~120-line TypeScript file (src/index.ts) exporting one factory function that creates an emitter instance backed by a Map<EventType, Handler[]>; on, off, and emit are plain functions closing over that map rather than class methods, which is what allows the entire implementation to be so small and to avoid this-binding footguns. Tech Stack - Pure TypeScript with no runtime dependencies, compiled to ESM, CommonJS, and UMD builds for universal consumption; the UMD build is distributed via unpkg for direct <script> tag usage. Code Quality - The repository includes a dedicated index_test.ts covering core emitter behavior and a test-types-compilation.ts file specifically verifying the TypeScript generic inference works as documented — an unusually thorough test investment for a library this small, reflecting how central correct typing is to its value proposition. API Design - The three-method surface (on, off, emit) plus the wildcard '*' convention is deliberately tiny and immediately familiar to anyone who has used Node’s EventEmitter, while the TypeScript generics let consumers get compile-time safety on event names and payload shapes with minimal ceremony — a rare combination of minimalism and type safety.
Used by 17 apps in this directory
Krayin CRM
CRM · Ecommerce
Free, open-source Laravel & Vue.js CRM for SMEs and enterprises to manage the complete customer lifecycle.
Mixpost
Marketing · Social Media
Self-host your own social media scheduler and publish to 11 platforms without subscriptions or data lock-in.
NoteGen
AI Assistants · Knowledge Management · Note Taking
Capture anything first, then let AI transform your scattered records into polished, structured Markdown notes with RAG-powered knowledge retrieval.
Novu
Developer Tools
Open-source communication infrastructure that connects your products and AI agents to every channel your users live on — Inbox, Email, SMS, Push, Chat, and more.
OpenPanel
Analytics
Open-source Mixpanel alternative with session replay, MCP integration, and privacy-first product analytics you fully control.
Refly
AI Development · Automation · No Code Platforms
Build deterministic, versioned agent skills from natural language—run them anywhere from Claude Code to Slack.
Tabby
AI Code Assistants
Self-hosted AI coding assistant — run GitHub Copilot-grade code completion on your own hardware with no cloud dependency.
Uptime Kuma
Monitoring
Self-hosted monitoring for every service you run — 23 monitor types, 95 notification channels, live dashboards, and public status pages with no vendor lock-in.