js-cookie-vue
TypeScript icon, indicating that this package has built-in type declarations

1.0.8 • Public • Published

JS-Cookie-Vue

A simple, lightweight Vue plugin for handling cookies

  • Why reinvent the wheel?
    Instead of making yet another cookie-handling library, JS-Cookie-Vue uses the popular JavaScript Cookie library (with over 16k stars ⭐️ at the time of writing) to handle all the cookie logic. Guarenteeing its bullet-proofness
  • Minimal and robust Vue.js plugin wrapper, making this the easiest way to integrate safe cookies into your application
  • (obligatory) Blazing fast 💨

Use

As easy as

// main.js
import JSCookieVue from 'js-cookie-vue';
 
Vue.use(JsCookieVue)
// component.vue
 
this.$cookies.set('testName', ['test', 'value'])
// use `getJSON` to automatically parse complex values
this.$cookies.getJSON('testName') // ===['test', 'value']

Please see JavaScript Cookie documentation for all uses.

Config

// main.js
 
import JSCookieVue from 'js-cookie-vue';
 
Vue.use(JsCookieVue, {
  sameSite: 'lax',
  // Use Webpack to inline values like this at compile-time
  secure: !process.env.NODE_ENV || process.env.NODE_ENV === 'production',
})

Please see JavaScript Cookie documentation for all attribute options.

Inspired by js-cookie and vue-cookies

Package Sidebar

Install

npm i js-cookie-vue

Weekly Downloads

1

Version

1.0.8

License

GPLv2

Unpacked Size

3.3 kB

Total Files

5

Last publish

Collaborators

  • emceemc