A nuxt(2) module to persist vuex state with cookie.
# yarn
$ yarn add --dev nuxt-persiststate-with-cookie
# npm
$ npm i -D nuxt-persiststate-with-cookie
There are some ways for using nuxt-persiststate with cookie.
- Basic.
// nuxt.config.js
module.exports = {
// ...
buildModules: [['nuxt-persiststate-with-cookie']],
}
- With configuration parameters.
// nuxt.config.js
module.exports = {
// ...
buildModules: [
[
'nuxt-persiststate-with-cookie',
{
key: 'my-custom_cookie_key',
// ...
},
],
],
// Or
persiststate: {
// your config
},
}
- Apply to a third-party nuxt module via
requireModule
method.
// ...
moduleObject.requireModule([
'nuxt-persiststate-with-cookie',
{
// your config
},
])
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. |
see CHANGE LOG