π
Welcome to @ekwoka/persistedstore
Simple Tool for having Alpine Stores persist across pages and sessions. This is based on @ryangjchandler/fern with a few improvements.
Install
npm i @ekwoka/persistedstore
Usage
Import and install persistedStore to your bundle with AlpineJS:
import Alpine from 'alpinejs';
import persistedStore from '@ekwoka/persistedstore';
Alpine.plugin(persistedStore);
Alpine.start();
Use wherever you would a conventional Alpine Store:
Alpine.persistedStore('darkMode',false);
Refer in the same way you would a normal store:
<button @click="$store.darkMode=true">π</button>
This version of persistedStore supports all primitive types, arrays, and objects. It also supports getters
in the Store Object.
Author
- Website: http://thekwoka.net
- Github: @ekwoka
Show your support
Give a