Skip to content

Files

Latest commit

cea8897 · Mar 15, 2025

History

History
44 lines (34 loc) · 1.44 KB

README.md

File metadata and controls

44 lines (34 loc) · 1.44 KB

message-bridge

Web/h5/mp bridge for web/mp.

version license size download

installation

yarn add @jswork/message-bridge

usage

import messageBridge from '@jswork/message-bridge';

// Register a handler for incoming messages
messageBridge.registerHandler('message:in', (data, responseCallback) => {
  console.log('Received data:', data);
  // Send response back
  responseCallback({ status: 'success' });
});

// Send a message and handle the response
messageBridge.callHandler('message:out', { type: 'request', payload: 'Hello!' }, (response) => {
  console.log('Got response:', response);
});

license

Code released under the MIT license.