Get to know MDN better
This feature is well established and works across many devices and browser versions. It’s been available across browsers since April 2018.
Note: This feature is only available in Service Workers.
The postMessage() method of the Client interface allows a service worker to send a message to a client (a Window, Worker, or SharedWorker). The message is received in the message event on navigator.serviceWorker.
The message to send to the client. This can be any structured-cloneable type.
Note: A service worker is not in the same agent cluster as its client, and therefore cannot share memory. SharedArrayBuffer objects, or buffer views backed by one, cannot be posted across agent clusters. Trying to do so will generate a messageerror event containing a DataCloneError DOMException on the receiving end.
An optional array of transferable objects to transfer ownership of. The ownership of these objects is given to the destination side and they are no longer usable on the sending side. These transferable objects are not automatically sent; they must either be contained in the message or be accessible to the recipient via other means, such as MessagePort via MessageEvent.ports.
options OptionalAn optional object containing the following properties:
transfer OptionalHas the same meaning as the transfer parameter.
None (undefined).
The code below sends a message from a service worker to a client. The client is fetched using the get() method on clients, which is a global in service worker scope.
Receiving that message:
| Service Workers Nightly # dom-client-postmessage-message-options |
Enable JavaScript to view this browser compatibility table.
This page was last modified on Apr 13, 2026 by MDN contributors.
Your blueprint for a better internet.
Visit Mozilla Corporation’s not-for-profit parent, the Mozilla Foundation.
Portions of this content are ©1998–2026 by individual mozilla.org contributors. Content available under a Creative Commons license.