beeeku / cookieplus

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Welcome to cookieplus 👋

Version License: MIT Twitter: beeeku

Nicer way to manage your cookies

Install

npm install @beeeku/cookieplus
yarn add @beeeku/cookieplus

Importing library

import { getCookie, setCookie, removeCookie, clearCookie } from '@beeeku/cookieplus';

Usage

const times = parseInt(getCookie('times'), 10) || 0;
setCookie('times', times + 1);
removeCookie('times');
clearCookie();

Demo

CodeSandbox

API

getCookie(key)

Return the cookie value for key.

setCookie(key, value, opts={})

Set the cookie at key to value with optional parameters expires and path.`.

removeCookie(key)

Removes cookie value stored at key.`.

clearCookie()

Removes all currently available cookies.

Inspiration

Implemented with typescript from https://github.com/substack/cookie-cutter

Author

👤 Bikash Dash

Show your support

Give a ⭐️ if this project helped you!

About

License:MIT License


Languages

Language:TypeScript 100.0%