@vue-composable/cookie
TypeScript icon, indicating that this package has built-in type declarations

1.0.0-beta.24 • Public • Published

@vue-composable/cookie

vue-composable logo

npm version

bundle size

Introduction

Use js-cookie library with the composition-api

Vue 3

Vue3 aka vue-next is fully supported

Installing

# @vue/composition-api

# install with yarn
yarn add @vue/composition-api @vue-composable/cookie

# install with npm
npm install @vue/composition-api @vue-composable/cookie


# vue-next / vue@3.0.0

# install with yarn
yarn add @vue-composable/cookie

# install with npm
npm install @vue-composable/cookie

Documentation

Check our documentation

<template>
  <div>
    cookie value: {{ cookie }}
    <p>
      <button @click="updateCookie">Update Cookie</button>
    </p>
    <p>
      <button @click="deleteCookie">Remove Cookie</button>
    </p>
  </div>
</template>

<script>
import { defineComponent } from "@vue/composition-api";
import { useCookie } from "@vue-composable/cookie";

export default defineComponent({
  name: "cookie-example",

  setup() {
    let idx = 0;

    let { cookie, setCookie, removeCookie } = useCookie("my-cookie");

    function updateCookie() {
      cookie.value = `my-cookie-${++idx}`;
    }

    function deleteCookie() {
      removeCookie();
    }

    return {
      cookie,

      updateCookie,
      deleteCookie,
    };
  },
});
</script>

Contributing

  1. Fork it!
  2. Create your feature branch: git checkout -b feat/new-composable
  3. Commit your changes: git commit -am 'feat(composable): add a new composable'
  4. Push to the branch: git push origin feat/new-composable
  5. Submit a pull request

Build

# install packages
yarn

# build and test for v2
yarn build --version=2
yarn test:vue2

# build and test for v3
yarn build
yarn test

New composable

  1. Fork it!
  2. Create your feature branch: git checkout -b feat/new-composable
  3. Commit your changes: git commit -am 'feat(composable): add a new composable'
  4. Push to the branch: git push origin feat/new-composable
  5. Submit a pull request

License

MIT

Package Sidebar

Install

npm i @vue-composable/cookie

Weekly Downloads

61

Version

1.0.0-beta.24

License

MIT

Unpacked Size

29.3 kB

Total Files

27

Last publish

Collaborators

  • pikax