@delphington/persistent-buckets

Versioned localStorage buckets with shared Vue state
183
Install
npm install @delphington/persistent-buckets
Latest Version:0.1.0
Vue:3
License:MIT
Last Updated:Sep 14, 2026
Links: GitHub  ·  npm
Maintainer: delphington

persistent-buckets

Versioned localStorage buckets backed by shared Vue refs.

Usage

import { defineBucket } from '@delphington/persistent-buckets';

type Preferences = {
  theme: 'light' | 'dark';
};

export const preferences = defineBucket<Preferences>({
  key: 'example:preferences',
  version: 0,
  initial: { theme: 'light' },
  migrate(version, stored) {
    if (version !== 0) throw new Error('Unsupported preferences version');
    return stored as Preferences;
  },
});

state is a shared Vue ref. Changes must be saved explicitly:

const state = preferences.state;
state.value.theme = 'dark';
preferences.save();

Bucket modules self-register when they are imported. Import every bucket at the application's entry point so aggregate operations always use the complete set:

import './persistence/buckets/history';
import './persistence/buckets/preferences';

Vite applications can instead eagerly import a bucket directory:

import.meta.glob('./persistence/buckets/*.ts', { eager: true });

Only imported buckets are included by persistence.dump(), persistence.restore(), persistence.reset(), and persistence.prune().

Bucket data must be JSON-serializable. If localStorage is unavailable, data is kept in memory and persistence.ephemeral is true.

Related Packages

vuejs-storage

Vue.js and Vuex plugin to persistence data with localStorage/sessionStorage

14,982 120
vuex-along

Automatically restore vuex state after refreshing the page

10,136 259
vue-lsd

Plugin to sync vue instance data to localStorage

1,214 3
vuex-masked-modules

Plugin for working with Vuex. Allows to use localeStorage to store state. It is...

1,001 3
vuex-persist

A Vuex persistence plugin in Typescript

2,829,593 1,645

Version History

Version Released Vue License
0.1.0 ^3.5.0 MIT