An Interest In:
Web News this Week
- April 21, 2024
- April 20, 2024
- April 19, 2024
- April 18, 2024
- April 17, 2024
- April 16, 2024
- April 15, 2024
[JS/TS] Cookie Muncher - Effortless cookie management
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): string
httpCookie.parse(cookies: string): Cookie[]
HttpCookieOptions
domCookie
Create, update, remove and get cookies from browser DOM.
domCookie.set(cookie: Cookie, options?: DomCookieOptions): void
domCookie.get(name: string): Cookie | null
domCookie.getAll(): Cookie[]
domCookie.remove(name: string, options?: DomCookieOptions): void
DomCookieOptions
This package will definitely be your best friend the next time you need to use cookies!
# NPMnpm install cookie-muncher# YARNyarn add cookie-muncher# PNPMpnpm install cshookie-muncher
Feel free to drop a on the GitHub repo or contribute!
Original Link: https://dev.to/bluzzi/jsts-cookie-muncher-effortless-cookie-management-1nfn
Dev To
An online community for sharing and discovering great ideas, having debates, and making friendsMore About this Source Visit Dev To