@the-link/tab
v0.3.0
Published
Browser tab transport for The Link.
Readme
The Link Tab
Same-origin browser tab transport for The Link. TabLink maps outbound events
to a BroadcastChannel and publishes messages received from other channel
members through its inbound tunnel.
Install
npm install @the-link/tabUsage
Create the same namespace in every tab or window that should communicate.
import { TabLink } from "@the-link/tab"
const tabs = new TabLink("workspace")
tabs.$inbound.subscribe("document:changed", document => {
console.log("Changed in another tab", document)
})
await tabs.$outbound.publish("document:changed", {
id: "document-42",
title: "The Link"
})
tabs.close()The browser delivers a broadcast to other BroadcastChannel instances using
the same namespace and origin. Payloads use the platform's structured-clone
algorithm, so this transport does not apply the Core byte codec and does not
require a server.
Calling close() leaves the namespace and releases the underlying
BroadcastChannel.
Development
bun install --frozen-lockfile
bun run verifyLicense
MIT
