Valtio adapter for state-sync — automatic proxy synchronization
npm install @statesync/valtioValtio adapter for state-sync. Applies snapshots to a Valtio proxy.
``bash`
npm install @statesync/valtio @statesync/core
`typescript
import { createRevisionSync } from '@statesync/core';
import { createValtioSnapshotApplier } from '@statesync/valtio';
import { proxy } from 'valtio';
const state = proxy({ theme: 'light', lang: 'en' });
const applier = createValtioSnapshotApplier(state);
const handle = createRevisionSync({
topic: 'settings',
subscriber: mySubscriber,
provider: myProvider,
applier,
});
await handle.start();
`
`typescript`
const applier = createValtioSnapshotApplier(state);
// Assigns filtered keys directly on the proxy
`typescript`
const applier = createValtioSnapshotApplier(state, { mode: 'replace' });
// Deletes allowed keys not in new state, then assigns new keys
- The proxy reference is never replaced — mutations are applied directly
- Existing Valtio subscribers (useSnapshot) continue to work
- toState(data, ctx) — map snapshot data to state patchpickKeys
- / omitKeys — limit which keys are updatedstrict
- (default: true) — throw if toState` returns a non-object
See full documentation.