Skip to content

gkshi/nuxt-cookie

Repository files navigation

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

  1. Include plugin in nuxt config
// nuxt.config.js
export default {
  plugins: [
    'node_modules/nuxt-cookie'
  ],

  // optional config
  nuxtCookie: {
    prefix: 'projectname_',
    defaultOptions: {} // such as path, expired, samesite etc
  }
}

 

Basic usage

// 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')

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published