@statesync/pinia
Pinia adapter for state-sync — automatic store synchronization
926
18
| Install | |
|---|---|
npm install @statesync/pinia |
|
| Latest Version: | 2.0.0 |
| License: | MIT |
| Last Updated: | Feb 13, 2026 |
| Links: | GitHub · npm |
Maintainer: ilyazelenko
@statesync/pinia
Pinia adapter for state-sync. Applies snapshots to a Pinia store.
Install
npm install @statesync/pinia @statesync/core
Quick Start
import { createRevisionSync } from '@statesync/core';
import { createPiniaSnapshotApplier } from '@statesync/pinia';
const store = useMyStore();
const applier = createPiniaSnapshotApplier(store);
const handle = createRevisionSync({
topic: 'settings',
subscriber: mySubscriber,
provider: myProvider,
applier,
});
await handle.start();
Modes
Patch (default)
const applier = createPiniaSnapshotApplier(store);
// Calls store.$patch(data) — merges fields
Replace
const applier = createPiniaSnapshotApplier(store, { mode: 'replace' });
// Full replacement: deletes missing keys, assigns new ones
Options
toState(data, ctx)— map snapshot data → state patchpickKeys/omitKeys— limit which keys are updatedstrict(default:true) — throw iftoStatereturns a non-object
See full documentation.
Related Packages
Version History
| Version | Released | License |
|---|---|---|
| 2.0.0 | MIT | |
| 1.0.0 | MIT |