All Projects → wobsoriano → pinia-shared-state

wobsoriano / pinia-shared-state

Licence: MIT License
🍍 A lightweight plugin to sync your pinia state across browser tabs.

Programming Languages

typescript
32286 projects
Vue
7211 projects
HTML
75241 projects

Projects that are alternatives of or similar to pinia-shared-state

dotto.x
A tiny state manager for React, Svelte, Vue and vanilla JS
Stars: ✭ 104 (+103.92%)
Mutual labels:  state-management
vue-stores
Share the root states and methods in every component.
Stars: ✭ 16 (-68.63%)
Mutual labels:  state-management
react-store
A library for better state management in react hooks world
Stars: ✭ 34 (-33.33%)
Mutual labels:  state-management
okwolo
light javascript framework to build web applications
Stars: ✭ 19 (-62.75%)
Mutual labels:  state-management
reactive-store
A store implementation for state management with RxJS
Stars: ✭ 29 (-43.14%)
Mutual labels:  state-management
ractor
class action based state management inspired by Redux and Akka Actor
Stars: ✭ 65 (+27.45%)
Mutual labels:  state-management
flutter-bloc-patterns
A set of most common BLoC use cases built on top of flutter_bloc library
Stars: ✭ 58 (+13.73%)
Mutual labels:  state-management
Nanny-State
simple state management
Stars: ✭ 68 (+33.33%)
Mutual labels:  state-management
react-smart-app
Preconfiguration React + Ant Design + State Management
Stars: ✭ 13 (-74.51%)
Mutual labels:  state-management
atomic-state
A decentralized state management library for React
Stars: ✭ 54 (+5.88%)
Mutual labels:  state-management
kladi
Easy to use state management library for React
Stars: ✭ 24 (-52.94%)
Mutual labels:  state-management
react-mui-pro-starter
Mix of Create React App and Material UI with set of reusable components and utilities to build professional React Applications faster.
Stars: ✭ 14 (-72.55%)
Mutual labels:  state-management
zoov
Use 🐻 Zustand with Module-like api
Stars: ✭ 24 (-52.94%)
Mutual labels:  state-management
closeable-map
Application state management made simple: a Clojure map that implements java.io.Closeable.
Stars: ✭ 42 (-17.65%)
Mutual labels:  state-management
pinia-plugin-persistedstate
🍍 Configurable persistence and rehydration of Pinia stores.
Stars: ✭ 134 (+162.75%)
Mutual labels:  pinia
xstate-cpp-generator
C++ State Machine generator for Xstate
Stars: ✭ 33 (-35.29%)
Mutual labels:  state-management
micro-observables
A simple Observable library that can be used for easy state management in React applications.
Stars: ✭ 78 (+52.94%)
Mutual labels:  state-management
k-ramel
State manager for your components apps, the safe and easy way
Stars: ✭ 20 (-60.78%)
Mutual labels:  state-management
react-stateful-component
Functional stateful React components with sideEffect support
Stars: ✭ 19 (-62.75%)
Mutual labels:  state-management
statebot
Write more robust and understandable programs. Statebot hopes to make Finite State Machines a little more accessible.
Stars: ✭ 24 (-52.94%)
Mutual labels:  state-management

pinia-shared-state

npm version bundle size

A lightweight module to sync your pinia state across browser tabs. Supports Vue 2 and 3.

Requirements

  • pinia@beta
  • vue ^2.6.14 || ^3.2.0

Install

yarn add pinia@beta pinia-shared-state

Usage

import { PiniaSharedState } from 'pinia-shared-state'

// Pass the plugin to your application's pinia plugin
pinia.use(PiniaSharedState({
    // Enables the plugin for all stores. Defaults to true.
    enable: true,
    // If set to true this tab tries to immediately recover the shared state from another tab. Defaults to true.
    initialize: false
}))
const useStore = defineStore({
  id: 'counter',
  state: () => ({
      count: 0,
      foo: 'bar'
  }),
  share: {
      // An array of fields that the plugin will ignore.
      omit: ['foo'],
      // Override global config for this store.
      enable: true,
      initialize: true
  }
});

Don't want to use it as a plugin? You can share state on your own:

import { defineComponent } from 'vue'
import { share, unshare } from 'pinia-shared-state'
import useStore from './store'

export default defineComponent({
    setup() {
        const counterStore = useStore()
        
        // Call `unshare` method to close the channel
        unshare()
    }
})

Credits

  • pinia - 🍍 Intuitive, type safe, light and flexible Store for Vue using the composition api with DevTools support.
  • vue-demi - Creates Universal Library for Vue 2 & 3.
  • broadcast-channel - BroadcastChannel to send data between different browser-tabs or nodejs-processes.

License

MIT License.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].