Evil Martians·
How to make postMessage type-safe in under 350 bytes
TL;DR
Browser messaging with postMessage requires repetitive routing, cleanup, and reply-handling code, while leaving message names and payloads unchecked. Evil Martians’ typed-channel uses shared TypeScript message definitions and interchangeable transports to provide one checked API across workers, iframes, tabs, and in-page events. The core plus postMessage transport weighs just 341 bytes compressed, while optional request/response support adds typed replies and cancellation that reaches the receiving handler.
Relevant links
Sign in to save links