OSS TanbouSign in with GitHub

manage browser cookie creation, reads, removal, and attributes through a small JavaScript API

About these scores

OSS scale score is an unbounded metric that log-compresses and weights Stars, Watchers, Forks, and Contributors. Discovery score is the current OSS scale score minus the score at discovery. Update pace is commits in the last 30 days, growth momentum is the OSS scale score difference within the recent observation window, and OSS health is a 0–100 rating based on available recency, Community Health, and release data.

Stars
22,573
Primary language
JavaScript
License
MIT
Repository last updated
Sep 17, 2026
On this page

Overview

js-cookie is a lightweight JavaScript library that wraps client-side cookie operations in Cookies.set, get, and remove. It applies RFC 6265-compatible encoding and accepts attributes such as expiry, path, domain, secure, and sameSite as an object.

Features and best fit

Based on official documentation; not hands-on tested · Content checked:

Key features

Create, read, and remove cookies through one API

Cookies.set() writes a value and its attributes, Cookies.get() reads cookies visible to the current page, and Cookies.remove() deletes them. The library has no dependencies.

Sources: [1]

Declare expiry, path, domain, secure, and sameSite attributes

Per-cookie attributes are passed to Cookies.set(), while withAttributes() creates an API instance with shared defaults for repeated use.

Sources: [1]

Choose ES module or UMD/CommonJS distribution formats

The npm package exposes an ES module through its module field and a UMD build through browser, supporting both bundler-oriented and classic script integration.

Sources: [1][2]

Best fit

Fits browser interfaces that need a small explicit cookie state layer

It is useful for preferences, consent state, and other short browser-visible values when a frontend wants one consistent API instead of hand-building document.cookie strings.

Sources: [1]

Before adoption

Deletion must repeat the attributes used when the cookie was created

When a cookie uses non-default path, domain, secure, or sameSite values, Cookies.remove() must receive the same values or the cookie will remain.

Sources: [1]

Read visibility is determined by the current browser context

Passing domain or path attributes to Cookies.get() does not change its search scope. A cookie is returned only when browser cookie rules make it visible from the current page.

Sources: [1]

Official sources

  1. [1]js-cookie 3.0.8 README(2026-10-05)
  2. [2]js-cookie 3.0.8 package metadata(2026-10-05)
  3. [3]js-cookie 3.0.8 release(2026-10-05)
  4. [4]js-cookie security policy(2026-10-05)
  5. [5]js-cookie MIT license(2026-10-05)
Supplemental curator note

js-cookie is practical when a browser application wants to avoid hand-building document.cookie strings while keeping cookie attributes explicit. Pay particular attention to deletion: non-default path, domain, secure, and sameSite attributes must match the values used when the cookie was created.

Try it in 3 steps

  1. 1

    Install js-cookie 3.0.8 in an isolated project

    Pin the current release and inspect its browser distribution without changing an existing project.

    demo=$(mktemp -d "${TMPDIR:-/tmp}/js-cookie.XXXXXX") && cd "$demo" && npm init -y >/dev/null && npm install --save-exact js-cookie@3.0.8
  2. 2

    Create minimal HTML that sets, reads, and removes a cookie

    Load the UMD build and exercise the documented set/get/remove flow while repeating the same sameSite attribute for removal.

    printf "%s\n" '<!doctype html>' '<meta charset="utf-8">' '<script src="./node_modules/js-cookie/dist/js.cookie.js"></script>' '<script>' "Cookies.set('oss-tanbou-demo', 'ok', { sameSite: 'strict' });" "document.body.textContent = Cookies.get('oss-tanbou-demo');" "Cookies.remove('oss-tanbou-demo', { sameSite: 'strict' });" '</script>' > index.html
  3. 3

    Open the HTML in a browser and verify the value

    Open index.html in a browser and confirm the page shows ok; the script removes the demo cookie afterward.

    index.html
Check the official README

Growth

Growth trends · Last 30 days

22,573 Stars

Trend data is still being collected.

Development activity

Last 90 days · weekly

Commits (last 30 days)
1
Open PRs
7

Development activity is still being collected.

Built with

Categories and tags

Categories

GitHub data

GitHub dataView detailed GitHub data

GitHub Topics

  • cookie
  • javascript
Stars
22,573
Forks
2,042
Watchers
329
Open issues
3
Contributors
56
Owner type
Organization
Primary language
JavaScript
License
MIT
Repository last updated
Sep 17, 2026
Write a related article

Share a guide or use case for this OSS in Markdown. Articles are published after administrator approval.

Report incorrect information

Tell us if any listing information is incorrect or outdated.

After reading this page, do you know what to do next?