mrkeyoor.com_
Thu 17 Sept 13:42 UTC
Webevaluationupdated 17 Sept 2026

js-cookie review

js-cookie is a client-side JavaScript wrapper around `document.cookie` for setting, reading, and deleting browser cookies. It handles expiration and cookie attributes without making you parse the cookie string yourself, while keeping the shipped package free of runtime dependencies.

Verdict

Our js-cookie run installed 927 packages in 47 seconds and used 622 MB, then passed all 4 tests in 7 seconds. Use it when browser code needs a compact, readable wrapper around document.cookie and your team understands cookie attributes. Choose a server cookie package for HttpOnly sessions, header parsing, duplicate names, or a stateful cookie jar.

We ran it

Lab card: what happened when we ran js-cookieScreenshot of js-cookie (github.com/js-cookie/js-cookie)
Install✓ · 47s927 packages · 622 MB
Buildn/ano build script
Tests✓ · 7s4 passed · 0 failed of 4 (node:test)
Known vulns00 critical · 0 high · 0 moderate · 0 low (npm audit)
Repo50 files~2,465 lines of source · 0.6 MB · 4 CI workflows · tests dir

Answers from our run

Does js-cookie build from source?

Dependencies installed in 47 seconds (927 packages), and the project has no separate build step. We cloned commit dd0d558 into a clean Debian container with 3 CPUs and no project-specific setup.

Do js-cookie's tests pass?

Yes: 4 of 4 passed when we ran the project's own test command (node:test). Some failures need services or credentials a bare container does not have.

Does js-cookie have known vulnerabilities in its dependencies?

npm audit found none in the dependency tree at the time of our run.

Who should not use js-cookie?

Authentication systems that need server-set HttpOnly session cookies: the README defines js-cookie as client-side, so the browser session endpoint should own those cookies.

What are the alternatives to js-cookie?

cookie-es, Universal Cookie, tough-cookie. Our js-cookie run installed 927 packages in 47 seconds and used 622 MB, then passed all 4 tests in 7 seconds.

Setup4/5One-line app install; contributor tree reached 622 MB
Docs4/5Clear attribute warnings, converters, and server examples
Community4/5Pushed in September 2026; 10 open issues and pull requests
Maturity4/5v3.0.8 fixed regressions; browser scope is well defined

Who it’s for

Frontend developers storing preferences or other non-sensitive state in browser cookies.
Teams that want one small API for path, domain, secure, sameSite, and partitioned cookie attributes.
Widget and SDK authors who need custom encoding or a way to avoid a global Cookies name collision.
Older browser projects that still need an AMD or CommonJS build beside an ES module.

Who it’s NOT for

Authentication systems that need server-set HttpOnly session cookies: the README defines js-cookie as client-side, so the browser session endpoint should own those cookies.
Applications that must distinguish duplicate cookie names across paths or domains: open issue 813 documents that get() returns only the first matching value.
Sandboxed embeds that expect a built-in cookie capability check: open issue 823 shows document.cookie can throw without allow-same-origin, and js-cookie has no Cookies.enabled() method.
Mixed client and server stacks that need identical encoding without adapters: the server guide documents different handling in PHP, Rack, Tomcat, JBoss, and Express.

Setup reality

Our sandbox install succeeded in 47 seconds, adding 927 packages and occupying 622 MB. The checkout was 0.6 MB with about 2,465 source lines. The harness found no build script or target, so it skipped that step. Node:test finished in 7 seconds with 4 passed and 0 failed, while npm audit reported 0 known vulnerabilities.

Using the library in an application needs no account, secret, database, or hosted service. You can install it with npm or load its browser build from a CDN. TypeScript users need the separate @types/js-cookie package.

Cookie behavior still depends on browser rules. A removal call must repeat the original path, domain, secure, and sameSite attributes, and reads can see only cookies available to the current page. Cross-stack encoding may require a custom converter.

Version 3.0.8 keeps the API small and browser-only

js-cookie 3.0.8 wraps document.cookie with calls for setting, reading, and removing cookies, plus helpers for default attributes and custom converters. The README says the minified, gzipped browser code is under 800 bytes and has no runtime dependency. ES module and AMD or CommonJS builds cover both current bundlers and older integrations. That is enough for preference flags, referral values, and other browser-visible state without hand-parsing one semicolon-delimited string.

The narrow scope is the reason to pick it. Our checkout contained 50 files, around 2,465 source lines, and only 0.6 MB before dependencies. js-cookie does not run a session service, maintain a Node cookie jar, or provide a consent banner. It follows the browser's visibility rules and gives you a cleaner interface. If those rules already match your design, the package removes repetitive code without inventing a new storage model.

What happened when we ran it

Our sandbox installed the repository in 47 seconds, pulling 927 packages and taking 622 MB on disk. The harness found no script or target named build, so that step was skipped. This is a sharp contrast with the dependency-free browser package described in the README. Most of the weight belongs to contributor tooling such as linting, bundling, browser testing, formatting, and release automation rather than the code an application imports.

Node:test completed in 7 seconds with 4 passed and 0 failed. Npm audit found 0 known vulnerabilities across the installed tree. We ran commit dd0d558 in an unprivileged Node 22 container with 3 CPUs and 8 GB of RAM. The repository also had 4 CI workflow files and a tests directory, but no Dockerfile. These results show that the measured checkout installed and passed its available harness checks. They do not measure browser compatibility or application performance.

Version 3.0.8 makes cookie attributes explicit, including deletion

In js-cookie 3.0.8, a cookie defaults to path /, while expiration, domain, secure transport, SameSite behavior, and partitioning remain choices for the caller. withAttributes() can create an instance with shared defaults. The README gives one warning worth putting into a code review checklist: removal must use the same path, domain, secure, and sameSite values used when the cookie was created. A bare remove() can otherwise leave the intended cookie untouched.

Version 3.0.8 also inherits the browser's read boundary. Passing a domain or path to get() cannot reveal a cookie that the current page cannot see. Open issue 813 describes a second edge case: when several visible cookies share one name across different paths or domains, js-cookie returns the first match rather than all values. The current source stops scanning once it finds that name. Domain migrations should therefore include a cleanup plan and direct inspection of document.cookie.

Version 3.0.8 cannot turn client cookies into server sessions

js-cookie 3.0.8 runs in page JavaScript. It can write secure, sameSite, and partitioned attributes, yet its client-side position makes it the wrong owner for a server-controlled session cookie. Authentication endpoints should set and expire those cookies in HTTP responses. The package fits better for browser-readable values where the application deliberately accepts script access, size limits, path rules, and the possibility that users block cookies.

The server integration guide names 4 backend families in dedicated sections: PHP, Tomcat, JBoss, and Express, with a related Rack warning. Their encoding conventions are not identical. PHP can turn spaces into plus signs, while Express can prefix JSON cookie values with j:. js-cookie provides converters for such cases, but your team must define and test that contract. TypeScript declarations also live in the separate @types/js-cookie package rather than this repository.

Version 3.0.8 still has awkward iframe and duplicate-name cases

Version 3.0.8 has no Cookies.enabled() capability method. Open issue 823 reports that reading document.cookie inside a sandboxed iframe without allow-same-origin can raise a security error, and the request remained open after an update on January 6, 2026. Embedded widgets that run under someone else's sandbox policy should catch access failures and test the exact iframe permissions. A simple preference helper is less simple when the host page controls its storage access.

Release v3.0.8 arrived on May 29, 2026 and fixed two regressions from v3.0.7: lost ES5 compatibility and an accidental Node 20 minimum. GitHub recorded the last push on September 17, 2026, 22,585 stars, and 10 open issues and pull requests when fetched. Recent activity includes merged dependency updates and several open automated update pull requests. That is current maintenance, though the combined open count should not be read as 10 confirmed bugs.

The 622 MB contributor tree matters only if you work on the library

A 622 MB development install is substantial for a repository whose checkout was 0.6 MB, but application buyers receive the small runtime package rather than the full contributor toolchain. Maintainers and downstream packagers should budget for the 927-package setup and browser-oriented tooling. Product teams can judge the library on its actual boundary: browser-visible cookies, explicit attributes, custom encoding, and no server-side state management.

Choose js-cookie for a browser component that needs readable cookie operations and already has a server strategy for sensitive sessions. Choose cookie-es or jshttp/cookie when HTTP headers are the main interface, Universal Cookie for shared browser and server rendering, and tough-cookie for a Node.js jar that survives multiple requests. The useful line is concrete: js-cookie owns the page's document.cookie interaction, while your server still owns authentication and session policy.

Alternatives

ProjectWhat it isPick it when
cookie-esAn ESM parser and serializer for Cookie and Set-Cookie headers with built-in TypeScript types.pick this instead when your work centers on HTTP headers, server runtimes, or duplicate cookie values.
Universal CookieA shared cookie API with packages for JavaScript, React, Express, and Koa.pick this instead when the same cookie layer must work in the browser and during server rendering.
tough-cookieA Node.js CookieJar implementation that tracks cookie policy across requests.pick this instead when an HTTP client, test runner, or crawler needs a persistent cookie jar.

What people are saying

  1. [velocity-scout] js-cookie/js-cookie

Sources

  1. js-cookie repository
  2. js-cookie README
  3. js-cookie v3.0.8 release
  4. Server-side integration guide
  5. Issue 813: duplicate cookie values
  6. Issue 823: cookie access detection
  7. Measured commit dd0d558

More web reviews

ionic-framework · pixijs · django-rest-framework · gin · components · docs · the whole board →