Skip to content

Event Bridge

import { startEventBridge } from "webotron/plugins/event-bridge";
  • startEventBridge(view)
const bridge = await startEventBridge(view);
const listenerId = await bridge.on("click", (event) => {
console.log("clicked:", event.target?.id);
}, { selector: "#submitBtn" });
await bridge.off(listenerId);
await bridge.stop();
OptionTypePurpose
selectorstringAttach to a specific element.
targetwindow | document | bodyAttach to a global target.
capturebooleanCapture phase listener mode.
passivebooleanPassive listener mode.
oncebooleanAuto-remove listener after first event.
  • Registers a binding in the page.
  • Emits structured event payloads back to the host.
  • Supports selector-based, window, body, and document targets.