Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/vuebits/cookies
Vue 3 library for cookie management
https://github.com/vuebits/cookies
Last synced: 20 days ago
JSON representation
Vue 3 library for cookie management
- Host: GitHub
- URL: https://github.com/vuebits/cookies
- Owner: vuebits
- License: mit
- Created: 2021-03-04T11:07:12.000Z (almost 4 years ago)
- Default Branch: main
- Last Pushed: 2021-03-04T11:55:00.000Z (almost 4 years ago)
- Last Synced: 2024-12-19T17:02:28.527Z (25 days ago)
- Language: TypeScript
- Size: 171 KB
- Stars: 1
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
Vuebits cookies
*** Maintainers & Contributors welcome ***
Vue 3 library for cookies management
---
## Table of Contents
* [Installation](#installation)
* [API](#api)
* [Documentation](#documentation)## Installation
`npm i @vuebits/cookies` / `yarn add @vuebits/cookies`
And install in your entry file (e.g. `main.js`):
```javascript
import { createCookies } from '@vuebits/cookies';createApp(App).use(createCookies({ /* your config here */ })).mount('#app');
```## API
### Available functions:
* `createCookies (options: CookiesConfig)`:
```ts
interface CookiesConfig {
expireTimes?: string | number | Date;
path?: string;
domain?: string;
secure?: boolean;
sameSite?: string;
}
```### Vue instance properties and methods:
* `$cookies: Cookies`:
```ts
interface Cookies {
config(config: CookiesConfig): void;
set(keyName: string,
value: any,
expireTimes?: string | number | Date,
path?: string,
domain?: string,
secure?: boolean,
sameSite?: string): this;
get(keyName: string): any;
remove(keyName: string, path?: string, domain?: string): boolean;
isKey(keyName: string): boolean;
keys(): string[];
}
```### Examples
```vue
Set cookie "test"
Get cookie "test"
Remove cookie "test"
cookie "test": {{ cookie }}
import { defineComponent } from 'vue';
export default defineComponent({
name: 'App',
data () {
return {
cookie: null as any
};
},
methods: {
setCookie (): void {
this.$cookies.set('test', 123);
},
getCookie (): void {
this.cookie = this.$cookies.get('test');
},
removeCookie (): void {
this.$cookies.remove('test');
}
}
});```