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
Actual
Invoicing Finance
Local-first personal finance with envelope budgeting, end-to-end encryption, and multi-device sync — no subscription required.
Bagisto
Analytics · Ecommerce
Open-source Laravel eCommerce platform for building multi-vendor marketplaces, B2B stores, headless commerce, and AI-powered storefronts.
Baserow
No Code Platforms · Databases
Open-source no-code platform to build databases, apps, automations, and AI agents — self-hosted or cloud, with full data ownership.
Chatwoot
Customer Support
Open-source omnichannel customer support platform with AI-powered agents, live chat, and self-hosting — a full Intercom and Zendesk alternative.
DataEase
Analytics · Data Engineering · AI Assistants
Open-source BI tool with drag-and-drop dashboards, 20+ data source connectors, and AI-powered natural language queries — a self-hosted alternative to Tableau.
Dify
No Code Platforms · AI Development · Developer Tools
Visual LLM workflow platform with RAG pipelines, agent capabilities, and model management for building production AI applications.
Directus
CMS · Low Code Platforms
Connect any SQL database and get instant REST and GraphQL APIs, a visual management Studio, and a native MCP server for AI agents — free for most organizations.
Docmost
Productivity · Note Taking · Collaboration
Self-hosted collaborative wiki and knowledge base with real-time editing, diagrams, AI assistance, and enterprise access controls — a modern alternative to Confluence and Notion.
Jaaz
AI Design Tools · AI Agents
Open-source AI creative agent that turns visual sketches and canvas gestures into images and videos — no text prompts required.