Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/gkshi/nuxt-cookie
https://github.com/gkshi/nuxt-cookie
Last synced: 9 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/gkshi/nuxt-cookie
- Owner: gkshi
- License: other
- Created: 2020-02-06T11:53:27.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2021-04-30T15:59:24.000Z (over 3 years ago)
- Last Synced: 2024-10-17T18:57:12.749Z (19 days ago)
- Language: JavaScript
- Size: 334 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 6
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# nuxt-cookie
> Nuxt.js plugin works with browser and server side cookie.
### Installation
1. Install plugin via npm or yarn
```yarn add --dev nuxt-cookie```
2. Include plugin in nuxt config
```javascript
// nuxt.config.js
export default {
plugins: [
'node_modules/nuxt-cookie'
],// optional config
nuxtCookie: {
prefix: 'projectname_',
defaultOptions: {} // such as path, expired, samesite etc
}
}
```
### Basic usage
```javascript
// in vue component
this.$cookie.get('cookie_name_without_prefix')
this.$cookie.set('cookie_name_without_prefix', 'value', options)
this.$cookie.delete('cookie_name_without_prefix')// also available in context
context.app.$cookie.get('cookie_name_without_prefix')
context.app.$cookie.set('cookie_name_without_prefix', 'value', options)
context.app.$cookie.delete('cookie_name_without_prefix')
```