Message Relay

This recipe shows how to communicate between the service worker and a page and shows how to use a service worker to relay messages between pages.

Difficulty

Beginner

Use Case

The postMessage API is brilliant for passing messages between windows and iframes, and now we can use the service worker’s message event to act as a messenger.

Features and Usage

  • postMessage API
  • Service worker registration

Category

General Usage


Has it been useful?

Tell us what you think of this recipe by leaving a comment!