pinia-persist-share

0.0.6 • Public • Published

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
    },
  }
);

Dependencies (1)

Dev Dependencies (0)

    Package Sidebar

    Install

    npm i pinia-persist-share

    Weekly Downloads

    2

    Version

    0.0.6

    License

    MIT

    Unpacked Size

    2.83 kB

    Total Files

    3

    Last publish

    Collaborators

    • coder_rance