@naturalcycles/vue-lib

Useful functions for Vue.js

Usage no npm install needed!

<script type="module">
  import naturalcyclesVueLib from 'https://cdn.skypack.dev/@naturalcycles/vue-lib';
</script>

README

@naturalcycles/vue-lib

Useful functions for Vue.js 2.x

npm min.gz size code style: prettier

Features

createLocalStoragePlugin

LocalStorage persistence plugin for Vuex 3.x (compatible with Vue 2.x).

Works in Nuxt (!).

interface GlobalState {
  count: number
}

const emptyState: GlobalState = {
  count: 0,
}

export const localStoragePlugin = createLocalStoragePlugin<GlobalState>({
  emptyState,
})

export const store = new Vuex.Store<GlobalState>({
  mutations: {},
  plugins: [localStoragePlugin],
})