@vue-composable/cookie
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
- Fork it!
- Create your feature branch:
git checkout -b feat/new-composable
- Commit your changes:
git commit -am 'feat(composable): add a new composable'
- Push to the branch:
git push origin feat/new-composable
- 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
- Fork it!
- Create your feature branch:
git checkout -b feat/new-composable
- Commit your changes:
git commit -am 'feat(composable): add a new composable'
- Push to the branch:
git push origin feat/new-composable
- Submit a pull request