Skip to content

Sync your Pinia state across browser tabs.Only Supports vue3, easy as shit.

Notifications You must be signed in to change notification settings

coder-rance/pinia-persist-share

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Install

npm install pinia-persist-share

Description

Sync your Pinia state across browser tabs.Only Supports vue3, easy as shit!

Usage

// main.js
import { createApp } from "vue";
import { createPinia } from "pinia";
import App from "./App.vue";
import PiniaPersistShare from "pinia-persist-share";

const app = createApp(App);
const pinia = createPinia();

pinia.use(PiniaPersistShare);
app.use(pinia);

app.mount("#app");
// src/store/status.js
import { ref } from "vue";
import { defineStore } from "pinia";

export const useStatusStore = defineStore(
  "status",
  () => {
    const now = ref(Date.now());

    const setNow = (payload) => {
      now.value = payload;
    };

    return {
      now,
      setNow,
    };
  },
  {
    persistShare: {
      enabled: true, // enable plugin for this store
    },
  }
);

About

Sync your Pinia state across browser tabs.Only Supports vue3, easy as shit.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published