Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/yisibell/nuxt-persiststate-with-cookie
A nuxt(2) module to persist vuex state with cookie.
https://github.com/yisibell/nuxt-persiststate-with-cookie
cookie nuxt-module nuxt2 nuxtjs persist-state vuex
Last synced: about 1 month ago
JSON representation
A nuxt(2) module to persist vuex state with cookie.
- Host: GitHub
- URL: https://github.com/yisibell/nuxt-persiststate-with-cookie
- Owner: yisibell
- License: mit
- Created: 2022-06-28T02:02:58.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2023-04-01T05:19:14.000Z (almost 2 years ago)
- Last Synced: 2024-11-15T09:15:18.549Z (about 2 months ago)
- Topics: cookie, nuxt-module, nuxt2, nuxtjs, persist-state, vuex
- Language: JavaScript
- Homepage:
- Size: 90.8 KB
- Stars: 1
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# nuxt-persiststate-with-cookie
A nuxt(2) module to persist vuex state with cookie.
# Installation
```bash
# 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.
```js
// nuxt.config.jsmodule.exports = {
// ...buildModules: [['nuxt-persiststate-with-cookie']],
}
```2. With configuration parameters.
```js
// nuxt.config.js
module.exports = {
// ...buildModules: [
[
'nuxt-persiststate-with-cookie',
{
key: 'my-custom_cookie_key',
// ...
},
],
],// Or
persiststate: {
// your config
},
}
```3. Apply to a third-party **nuxt module** via `requireModule` method.
```js
// ...
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](https://github.com/js-cookie/js-cookie). |# CHANGE LOG
see [CHANGE LOG](./CHANGELOG.md)