Files
chrome-extensions-samples/functional-samples/tutorial.websockets/README.md
Sebastian Benz 2852c64790 Add WebSocket sample (#976)
* Add WebSocket sample

This sample demonstrates how to use a websocket in a service worker.

* add minimum chrome version

* Address comments

* add more detail to the readme
* make sure glitch instance is booted

* fix spelling
2023-07-05 13:18:27 +02:00

897 B

Chrome extension WebSocket example

This example demonstrates how to use WebSockets in a MV3 Chrome Extension. Starting with Chrome version M116, WebSocket activity will extend the service worker lifetime. In previous Chrome versions, the service worker will become inactive while waiting for messages and disconnect the WebSocket.

Running this extension

  1. Clone this repository.
  2. Load this directory in Chrome as an unpacked extension.
  3. Pin the extension from the extension menu.
  4. Click the extension's action icon to start a web socket connection.
  5. Click the extension's action again to stop the web socket connection.
  6. Check the service worker status to see when the service worker is active/inactive.