MCPcopy Index your code
hub / github.com/postaljs/postal.js

github.com/postaljs/postal.js @3.2.0 sqlite

repository ↗ · DeepWiki ↗ · release 3.2.0 ↗
403 symbols 1,103 edges 132 files 4 documented · 1%
README

postal

Pub/Sub message bus for JavaScript and TypeScript.

Features

  • TypeScript-first — full type inference on channels, topics, and message data
  • AMQP-style wildcards* matches a single topic segment, # matches zero or more
  • Channel-scoped messaging — isolate message domains with named channels
  • Request/handle RPC — built-in request/response pattern
  • Wire taps — global observers that see every message on the bus
  • Transport system — bridge pub/sub across iframes, workers, and browser tabs
  • Zero dependencies — no lodash, no nothing

Install

npm install postal

Quick Example

import { getChannel } from "postal";

const orders = getChannel("orders");

orders.subscribe("order.created", envelope => {
    console.log("New order:", envelope.payload.orderId);
});

orders.publish("order.created", { orderId: "abc-123" });

For the full API — wildcards, RPC, wire taps, transports — see the docs.

Upgrading from v2? postal v3 is a ground-up rewrite with breaking changes to the module system, subscriber callbacks, envelope shape, and more. See the v2 → v3 migration guide before upgrading.

Packages

Package npm Description
postal postal Core message bus
postal-transport-messageport postal-transport-messageport MessagePort transport for iframes and workers
postal-transport-broadcastchannel postal-transport-broadcastchannel BroadcastChannel transport for cross-tab messaging
postal-transport-serviceworker postal-transport-serviceworker ServiceWorker transport — dedicated MessagePort per tab, presence tracking, SW restart resilience
postal-transport-childprocess postal-transport-childprocess child_process/cluster IPC transport for Node.js

Development

pnpm install       # Install dependencies
pnpm build         # Build all packages
pnpm test          # Run all tests
pnpm lint          # Lint all packages
pnpm run checks    # lint + test + build (CI gate)

License

MIT

Extension points exported contracts — how you extend this code

ChannelRegistry (Interface)
(no doc)
packages/postal/src/channel.ts
GIFEncoderInstance (Interface)
(no doc)
examples/gif-stitch/src/gifenc.d.ts
ChannelRegistry (Interface)
(no doc)
examples/train-dispatch/src/types.ts
ChannelRegistry (Interface)
(no doc)
examples/ascii-camera/src/types.ts
ChannelRegistry (Interface)
(no doc)
examples/radio-spectrum-tui/src/types.ts

Core symbols most depended-on inside this repo

getChannel
called by 66
packages/postal/src/channel.ts
createChannel
called by 62
packages/postal/src/channel.ts
addTransport
called by 54
packages/postal/src/transport.ts
getEl
called by 40
examples/gif-stitch/src/ui.ts
matchTopic
called by 33
packages/postal/src/topicMatch.ts
createMessagePortTransport
called by 26
packages/postal-transport-messageport/src/messagePortTransport.ts
createEnvelope
called by 23
packages/postal/src/envelope.ts
amber
called by 22
examples/train-dispatch/src/ansi.ts

Shape

Function 373
Class 14
Method 11
Interface 5

Languages

TypeScript100%

Modules by API surface

packages/postal/src/channel.ts30 symbols
examples/gif-stitch/src/ui.ts28 symbols
examples/train-dispatch/src/ansi.ts22 symbols
examples/tab-sync/src/ui.ts18 symbols
examples/train-dispatch/src/display.ts15 symbols
examples/notification-dashboard/src/ui.ts13 symbols
examples/ascii-camera/src/ansi.ts13 symbols
examples/train-dispatch/src/split-flap.ts9 symbols
examples/radio-spectrum-tui/src/stream-reader.ts9 symbols
packages/postal/src/transport.ts8 symbols
packages/postal-transport-messageport/src/protocol.ts7 symbols
packages/postal-transport-childprocess/src/protocol.ts7 symbols

Dependencies from manifests, versioned

@apogeelabs/the-agency0.9.0 · 1×
@astrojs/starlight0.37.0 · 1×
@changesets/cli2.29.8 · 1×
@eslint/js9.39.2 · 1×
@tailwindcss/vite4.1.3 · 1×
@types/jest30.0.0 · 1×
@types/node22.15.0 · 1×
@types/react18.3.23 · 1×
@typescript-eslint/eslint-plugin8.55.0 · 1×
astro5.7.0 · 1×
chalk5.4.1 · 1×

For agents

$ claude mcp add postal.js \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact