files/en-us/web/api/broadcastchannel/postmessage/index.md
{{APIRef("BroadCastChannel API")}} {{AvailableInWorkers}}
The postMessage() method of the {{domxref("BroadcastChannel")}} interface sends a message,
which can be of any kind of {{jsxref("Object")}},
to each listener in any {{glossary("browsing context")}} with the same {{glossary("origin")}}.
The message is transmitted as a {{domxref("BroadcastChannel/message_event", "message")}} event
targeted at each {{domxref("BroadcastChannel")}} bound to the channel.
postMessage(message)
message
: Data to be sent to the other window. The data is serialized using the structured clone algorithm. This means you can pass a broad variety of data objects safely to the destination window without having to serialize them yourself.
[!NOTE] Execution contexts that can message each other may not be in the same agent cluster, and therefore cannot share memory. {{jsxref("SharedArrayBuffer")}} objects, or buffer views backed by one, cannot be posted across agent clusters. Trying to do so will generate a {{domxref("BroadcastChannel/messageerror_event", "messageerror")}} event containing a
DataCloneError{{domxref("DOMException")}} on the receiving end.
None.
InvalidStateError {{domxref("DOMException")}}
DataCloneError {{domxref("DOMException")}}
{{Specifications}}
{{Compat}}