Skip to content
Universal Storage Utilities for Nuxt.js
Branch: master
Clone or download
farzadso Merge pull request #17 from nuxt-community/renovate/jsdom-15.x
chore(deps): update dependency jsdom to v15
Latest commit 885e8dd Apr 22, 2019

README.md

Nuxt Universal Storage Module

npm (scoped with tag) npm CircleCI Codecov Dependencies js-standard-style

Universal Storage Utilities for Nuxt.js based on @nuxt-community/auth-module

📖 Release Notes

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 to modules section of nuxt.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 or npm install
  • Start development server using yarn run dev or npm run dev
  • Point your browser to http://localhost:3000

Roadmap

  • Add Encryption
  • Complete Documents
  • Universal Session Handling

License

MIT License - Alibaba Travels Co

You can’t perform that action at this time.