New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details
Socket
Book a DemoSign in
Socket

pinia-shared-state

Package Overview
Dependencies
Maintainers
1
Versions
41
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

pinia-shared-state

[![npm (tag)](https://img.shields.io/npm/v/pinia-shared-state?style=flat&colorA=000000&colorB=000000)](https://www.npmjs.com/package/pinia-shared-state) ![npm bundle size](https://img.shields.io/bundlephobia/minzip/pinia-shared-state?style=flat&colorA=000

latest
Source
npmnpm
Version
2.0.1
Version published
Weekly downloads
8.4K
-28.88%
Maintainers
1
Weekly downloads
 
Created
Source

pinia-shared-state

npm (tag) npm bundle size NPM

Sync your Pinia state across browser tabs.

Requirements

  • vue ^3.5.11

Install

npm install 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,
    // Enforce a type. One of native, idb, localstorage or node. Defaults to native.
    type: 'localstorage',
  }),
);
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,
  },
});

Vanilla usage:

import { share } from 'pinia-shared-state';
import { onMounted, onUnmounted } from 'vue';
import useStore from './store';

const counterStore = useStore();

onMounted(() => {
  const { unshare } = share('counter', counterStore, { initialize: true });

  onUnmounted(() => {
    // Call `unshare` method to close the channel
    unshare();
  });
});

License

MIT

FAQs

Package last updated on 24 Mar 2026

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts