pinia-colada-plugin-broadcast-sync
v0.1.0
Published
A Pinia Colada plugin that syncs your state across tabs using Broadcast Channel API
Readme
pinia-colada-plugin-broadcast-sync
Usage
Register the plugin when installing Pinia Colada
import { PiniaColada } from '@pinia/colada'
import { createPinia } from 'pinia'
import { PiniaColadaBroadcastSyncPlugin } from 'pinia-colada-plugin-broadcast-sync'
import { createApp } from 'vue'
import App from './App.vue'
const app = createApp(App)
const pinia = createPinia()
app.use(pinia)
app.use(PiniaColada, {
plugins: [PiniaColadaBroadcastSyncPlugin()],
})
app.mount('#app')Then all your changes in the state will be broadcasted to other tabs automatically.
Options
| Option | Type | Default | Description |
| :--- | :--- | :--- | :--- |
| broadcastChannelName | string | 'pinia-colada-plugin-broadcast-sync' | The name of the broadcast channel to use. |
You can set the options when installing the plugin:
PiniaColadaBroadcastSyncPlugin({
broadcastChannelName: 'my-broadcast-channel'
})