cookie-storage provides a Web Storage API-compatible interface for browser cookies, implementing the same methods as localStorage/sessionStorage (getItem, setItem, removeItem, clear, key, length) with additional cookie-specific options like path, domain, expires, secure, and sameSite. Current stable version is 6.1.0, released in 2023. The library is lightweight, ships TypeScript definitions, and supports ESM imports. Unlike raw document.cookie manipulation, it offers a cleaner API and automatic cookie string encoding/decoding. It is ideal for cross-browser cookie management with a familiar storage interface, but note that cookie storage is limited to ~4KB per cookie and 20-50 cookies per domain.
npm install cookie-storageNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Demonstrates creating a CookieStorage instance, setting/getting cookies with options, iterating over storage, and removing/clearing cookies.
Update your import to ESM syntax: import { CookieStorage } from 'cookie-storage'Switch to named import: import { CookieStorage } from 'cookie-storage'Use a storage event listener or consider using localStorage for cross-tab sync.
Do not rely on order; iterate via length and key() if needed, but prefer storing a list of keys manually.
Keep cookie sizes small and monitor total count. Use chunking or alternative storage for large data.
Change to: import { CookieStorage } from 'cookie-storage'Run 'npm install cookie-storage' and use correct import: const { CookieStorage } = require('cookie-storage')Add 'new': const cookieStorage = new CookieStorage()
Ensure document.cookie is available. For Node, use a cookie parser package or mock the API.
No dependency data recorded yet.