browser-communication

browser communication between tabs using localStorage

Usage no npm install needed!

<script type="module">
  import browserCommunication from 'https://cdn.skypack.dev/browser-communication';
</script>

README

browser-communication

This is a helper for communicating two or more browser tabs.

usage

There is two functions exported that you can use;

import { Data, fromStorage, publishStorage } from 'browser-communication';

interface User extends Data {
  id: number;
  username: string;
}

fromStorage<User>('user').subscribe(user => {
  // when someone calls publishStorage this 
  // this callback will be executed
  // local publishes are included though
});

publishStorage('user', {
  id: 3,
  username: 'john_doe'
});