When we create a website, we always need to use cookies, either on the browser side, or on the server side through the HTTP headers Cookie and Set-Cookie.
The problem is that most of the packages allowing to handle cookies are not maintained anymore, not written in TS, not exported in both CommonJS and ES module, not 100% compliant with RFC 6265, not complete enough and usable on both server and client side or simply don't have a good API...
That's why I created my own package : Cookie Muncher! A lightweight and typesafe package for manipulating cookies in NodeJS and the browser.
- π Lightweight
- π Works in all browsers
- π§ͺ Unit tested
- π· Typesafe
- π¦ Support ESM & CJS
- β RFC 6265 compliant
- π Well documented
This package is divided into two modules.
httpCookie
Serialize and parse cookie from HTTP headers Cookie and Set-Cookie.
httpCookie.serialize(cookie: Cookie, options?: HttpCookieOptions): stringhttpCookie.parse(cookies: string): Cookie[]HttpCookieOptions
domCookie
Create, update, remove and get cookies from browser DOM.
domCookie.set(cookie: Cookie, options?: DomCookieOptions): voiddomCookie.get(name: string): Cookie | nulldomCookie.getAll(): Cookie[]domCookie.remove(name: string, options?: DomCookieOptions): voidDomCookieOptions
This package will definitely be your best friend the next time you need to use cookies! πͺ
# NPM
npm install cookie-muncher
# YARN
yarn add cookie-muncher
# PNPM
pnpm install cshookie-muncher
Feel free to drop a β on the GitHub repo or contribute! π
Top comments (0)