Skip to content

Latest commit

 

History

History
90 lines (67 loc) · 2.07 KB

README.md

File metadata and controls

90 lines (67 loc) · 2.07 KB


nuxt-persiststate-with-cookie

A nuxt(2) module to persist vuex state with cookie.

Installation

# yarn
$ yarn add --dev nuxt-persiststate-with-cookie

# npm
$ npm i -D nuxt-persiststate-with-cookie

Usage

There are some ways for using nuxt-persiststate with cookie.

  1. Basic.
// nuxt.config.js

module.exports = {
  // ...

  buildModules: [['nuxt-persiststate-with-cookie']],
}
  1. With configuration parameters.
// nuxt.config.js
module.exports = {
  // ...

  buildModules: [
    [
      'nuxt-persiststate-with-cookie',
      {
        key: 'my-custom_cookie_key',
        // ...
      },
    ],
  ],

  // Or
  persiststate: {
    // your config
  },
}
  1. Apply to a third-party nuxt module via requireModule method.
// ...
moduleObject.requireModule([
  'nuxt-persiststate-with-cookie',
  {
    // your config
  },
])

Options

Key Default value Type Description
enable true boolean Whether to enable nuxt-persiststate-with-cookie
key __NUXT_PERSISTEDSTATE_VUEX__ string Specifies the key name used when storing the cookie.
paths ['site'] string[] Specify the state path to persist. By default, all states under the ~/store/site.ts module will be persisted.
setCookiesOptions { expires: 365, secure: false } object Specifies the configuration object for setting the cookie. For details, see The API of js-cookie.

CHANGE LOG

see CHANGE LOG