0.3.1 • Published 5 years ago
nuxt-universal-storage v0.3.1
Nuxt Universal Storage Module
Universal Storage Utilities for Nuxt.js based on @nuxt-community/auth-module
Setup
- Add
nuxt-universal-storage
dependency using yarn or npm to your project
yarn add nuxt-universal-storage
OR
npm install nuxt-universal-storage --save
- Add
nuxt-universal-storage
tomodules
section ofnuxt.config.js
{
modules: [
'nuxt-universal-storage',
],
storage: {
}
}
Usage
Options
Options are defined as following:
storage: {
vuex, // boolean or {namespace}
localStorage, // boolean or {prefix }
cookie, // boolean or {prefix, options }
initialState, // Object {}
ignoreExceptions //
}
and default to
{
vuex: {
namespace: 'storage'
},
cookie: {
prefix: '',
options: {
path: '/'
}
},
localStorage: {
prefix: ''
},
ignoreExceptions: false,
}
Api
$storage.getUniversal(key)
$storage.setUniversal(key, value)
$storage.syncUniversal(key, defaultValue)
$storage.removeUniversal(key)
$storage.getState(key)
$storage.setState(key, value)
$storage.removeState(key)
$storage.watchState(key, fn)
$storage.getLocalStorage(key)
$storage.setLocalStorage(key, value)
$storage.removeLocalStorage(key)
$storage.getCookies()
$storage.getCookie(key)
$storage.setCookie(key, value)
$storage.removeCookie(key)
Development
- Clone this repository
- Install dependencies using
yarn install
ornpm install
- Start development server using
yarn run dev
ornpm run dev
- Point your browser to
http://localhost:3000
Roadmap
- Add Encryption
- Complete Documents
- Universal Session Handling
License
MIT License - Alibaba Travels Co