mitt

Tiny (~200 byte) functional event emitter and pubsub for JavaScript and TypeScript

Library
npm
v3.0.1
11,903 stars
MIT License

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum. How we score it →
45 /100 Fair
Development Activity 0
Maintenance 20
Community 60
Maturity 60
Momentum 40

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation. How we score it →
76 /100 Good
Architecture 70
Code Quality 78
Innovation 62
Learning Curve 92

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/emit event emitter API modeled after Node’s EventEmitter, with no reliance on this
  • A wildcard '*' event type that listens to every emitted event, receiving both the event type and payload
  • Strong TypeScript generics — define an Events type map and get inferred, type-checked handler and payload types
  • Direct access to the underlying all Map 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

PHP
51%
MIT

Krayin CRM

CRM · Ecommerce

24,049

Free, open-source Laravel & Vue.js CRM for SMEs and enterprises to manage the complete customer lifecycle.

View details
90
Repo Health
68
Technical
67
Dependency
Built with
PHP 51%
Blade 41%
Updated 1 weeks ago
Vue
49%
MIT

Mixpost

Marketing · Social Media

3,854

Self-host your own social media scheduler and publish to 11 platforms without subscriptions or data lock-in.

View details
50
Repo Health
64
Technical
71
Dependency
Built with
Vue 49%
PHP 44%
Updated 7 months ago
TypeScript
89%
GPL 3.0

NoteGen

AI Assistants · Knowledge Management · Note Taking

12,914

Capture anything first, then let AI transform your scattered records into polished, structured Markdown notes with RAG-powered knowledge retrieval.

View details
87
Repo Health
74
Technical
67
Dependency
Built with
TypeScript 89%
Updated 6 days ago
TypeScript
98%
Other

Novu

Developer Tools

40,195

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.

View details
93
Repo Health
80
Technical
64
Dependency
Built with
TypeScript 98%
Updated 5 days ago
TypeScript
91%
AGPL 3.0

OpenPanel

Analytics

7,187

Open-source Mixpanel alternative with session replay, MCP integration, and privacy-first product analytics you fully control.

View details
83
Repo Health
74
Technical
64
Dependency
Built with
TypeScript 91%
Updated 6 days ago
TypeScript
96%
Other

Refly

AI Development · Automation · No Code Platforms

7,537

Build deterministic, versioned agent skills from natural language—run them anywhere from Claude Code to Slack.

View details
68
Repo Health
76
Technical
63
Dependency
Built with
TypeScript 96%
Updated 1 weeks ago
Rust
93%
Other

Tabby

AI Code Assistants

33,924

Self-hosted AI coding assistant — run GitHub Copilot-grade code completion on your own hardware with no cloud dependency.

View details
55
Repo Health
78
Technical
61
Dependency
Built with
Rust 93%
Updated 4 months ago
JavaScript
56%
MIT

Uptime Kuma

Monitoring

92,816

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.

View details
92
Repo Health
81
Technical
62
Dependency
Built with
JavaScript 56%
Vue 41%
Updated 5 days ago

Join founders buildingwith open source

Opinionated takes, migration guides, cost-saving tips, and insights from the open source ecosystem.

Subscribe on Substack
Join 750+ subscribers