@aaltra-devs/aaltra_universal-storage
v1.0.1
Published
A universal storage library for Nuxt projects.
Downloads
47
Maintainers
Readme
Universal Storage Helper
Universal storage helper for Nuxt projects with tweaks to facilitate use with older browsers.
Acknowledgments
This project is based on the Nuxt Community Universal Storage Module by Alibaba Travels Co - Nuxt Community, licensed under the MIT License. We have adapted and extended the original work to add compatibility improvements for older browsers (IE and Safari 10).
See the NOTICE file for the complete original license text.
Installation
npm i --save @aaltra-devs/aaltra_universal-storageCreate a nuxt plugin:
import Storage from "@aaltra-devs/aaltra_universal-storage";
export default function (ctx, inject) {
const options = {
vuex: {
namespace: "storage",
},
cookie: {
prefix: "",
options: {
path: "/",
},
},
localStorage: {
prefix: "",
},
ignoreExceptions: false,
};
const storage = new Storage(ctx, options);
ctx.$storage = storage;
inject("storage", storage);
}Features
- Universal storage support for Nuxt.js applications
- Works on both client and server side
- Supports localStorage, cookies, and Vuex state
- Synchronization between different storage mechanisms
- Compatible with IE and Safari 10
- Exception handling options
API
Methods
setUniversal(key, value)- Set value in all storage typesgetUniversal(key)- Get value from any storage typesyncUniversal(key, defaultValue)- Sync value across all storage typesremoveUniversal(key)- Remove value from all storage typessetState(key, value)- Set value in Vuex stategetState(key)- Get value from Vuex statesetLocalStorage(key, value)- Set value in localStoragegetLocalStorage(key)- Get value from localStoragesetCookie(key, value, options)- Set cookie valuegetCookie(key)- Get cookie value
License
This project is licensed under the BSD-3-Clause License - see the LICENSE file for details.
The original work this project is based on is licensed under the MIT License - see the NOTICE file for details.
