[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"project-3071":3},{"id":4,"name":5,"fullName":6,"owner":5,"repo":5,"description":7,"homepage":8,"htmlUrl":9,"language":10,"languages":9,"totalLinesOfCode":9,"stars":11,"forks":12,"watchers":13,"openIssues":14,"contributorsCount":15,"subscribersCount":15,"size":15,"stars1d":15,"stars7d":16,"stars30d":17,"stars90d":15,"forks30d":15,"starsTrendScore":14,"compositeScore":18,"rankGlobal":9,"rankLanguage":9,"license":19,"archived":20,"fork":20,"defaultBranch":21,"hasWiki":22,"hasPages":20,"topics":23,"createdAt":9,"pushedAt":9,"updatedAt":26,"readmeContent":27,"aiSummary":28,"trendingCount":15,"starSnapshotCount":15,"syncStatus":29,"lastSyncTime":30,"discoverSource":31},3071,"js-cookie","js-cookie\u002Fjs-cookie","A simple, lightweight JavaScript API for handling cookies, client-side.","",null,"JavaScript",22596,2052,327,3,0,4,14,73.34,"MIT License",false,"main",true,[24,25],"cookie","javascript","2026-06-12 04:00:16","\u003Cp align=\"center\">\n  \u003Cimg src=\"https:\u002F\u002Fcloud.githubusercontent.com\u002Fassets\u002F835857\u002F14581711\u002Fba623018-0436-11e6-8fce-d2ccd4d379c9.gif\">\n\u003C\u002Fp>\n\n# JavaScript Cookie [![CI](https:\u002F\u002Fgithub.com\u002Fjs-cookie\u002Fjs-cookie\u002Factions\u002Fworkflows\u002Fci.yml\u002Fbadge.svg)](https:\u002F\u002Fgithub.com\u002Fjs-cookie\u002Fjs-cookie\u002Factions\u002Fworkflows\u002Fci.yml) [![npm](https:\u002F\u002Fimg.shields.io\u002Fgithub\u002Fpackage-json\u002Fv\u002Fjs-cookie\u002Fjs-cookie)](https:\u002F\u002Fwww.npmjs.com\u002Fpackage\u002Fjs-cookie) [![size](https:\u002F\u002Fimg.shields.io\u002Fbundlephobia\u002Fminzip\u002Fjs-cookie\u002F3)](https:\u002F\u002Fwww.npmjs.com\u002Fpackage\u002Fjs-cookie) [![jsDelivr Hits](https:\u002F\u002Fdata.jsdelivr.com\u002Fv1\u002Fpackage\u002Fnpm\u002Fjs-cookie\u002Fbadge?style=rounded)](https:\u002F\u002Fwww.jsdelivr.com\u002Fpackage\u002Fnpm\u002Fjs-cookie)\n\nA simple, lightweight JavaScript API for handling cookies, client-side.\n\n- Extensive browser support\n- Accepts [any](#encoding) character\n- [Heavily](test) tested\n- No dependency\n- Supports both ES and AMD\u002FCommonJS modules\n- [RFC 6265](https:\u002F\u002Ftools.ietf.org\u002Fhtml\u002Frfc6265) compliant\n- Useful [Wiki](https:\u002F\u002Fgithub.com\u002Fjs-cookie\u002Fjs-cookie\u002Fwiki)\n- Enable [custom encoding\u002Fdecoding](#converters)\n- **\u003C 800 bytes** gzipped!\n\n**👉👉 If you're viewing this at https:\u002F\u002Fgithub.com\u002Fjs-cookie\u002Fjs-cookie, you're reading the documentation for the main branch.\n[View documentation for the latest release.](https:\u002F\u002Fgithub.com\u002Fjs-cookie\u002Fjs-cookie\u002Ftree\u002Flatest#readme) 👈👈**\n\n## Installation\n\n### NPM\n\n```bash\nnpm i js-cookie\n```\n\nThe npm package has a `module` field pointing to an ES module variant of the library, mainly to provide support for ES module aware bundlers, whereas its `browser` field points to an UMD module for full backward compatibility.\n\n_Not all browsers support ES modules natively yet_. For this reason the npm package\u002Frelease provides both the ES and UMD module variant and you may want to include the ES module along with the UMD fallback to account for this:\n\n### CDN\n\nAlternatively, include js-cookie via [jsDelivr CDN](https:\u002F\u002Fwww.jsdelivr.com\u002Fpackage\u002Fnpm\u002Fjs-cookie).\n\n## Basic Usage\n\nImport the library:\n\n```javascript\nimport Cookies from 'js-cookie'\n\u002F\u002F or\nconst Cookies = require('js-cookie')\n```\n\nCreate a cookie, valid across the entire site:\n\n```javascript\nCookies.set('name', 'value')\n```\n\nCreate a cookie that expires 7 days from now, valid across the entire site:\n\n```javascript\nCookies.set('name', 'value', { expires: 7 })\n```\n\nCreate an expiring cookie, valid to the path of the current page:\n\n```javascript\nCookies.set('name', 'value', { expires: 7, path: '' })\n```\n\nRead cookie:\n\n```javascript\nCookies.get('name') \u002F\u002F => 'value'\nCookies.get('nothing') \u002F\u002F => undefined\n```\n\nRead all visible cookies:\n\n```javascript\nCookies.get() \u002F\u002F => { name: 'value' }\n```\n\n_Note: It is not possible to read a particular cookie by passing one of the cookie attributes (which may or may not\nhave been used when writing the cookie in question):_\n\n```javascript\nCookies.get('foo', { domain: 'sub.example.com' }) \u002F\u002F `domain` won't have any effect...!\n```\n\nThe cookie with the name `foo` will only be available on `.get()` if it's visible from where the\ncode is called; the domain and\u002For path attribute will not have an effect when reading.\n\nDelete cookie:\n\n```javascript\nCookies.remove('name')\n```\n\nDelete a cookie valid to the path of the current page:\n\n```javascript\nCookies.set('name', 'value', { path: '' })\nCookies.remove('name') \u002F\u002F fail!\nCookies.remove('name', { path: '' }) \u002F\u002F removed!\n```\n\n_IMPORTANT! When deleting a cookie and you're not relying on the [default attributes](#cookie-attributes), you must pass the exact same `path`, `domain`, `secure` and `sameSite` attributes that were used to set the cookie:_\n\n```javascript\nCookies.remove('name', { path: '', domain: '.yourdomain.com', secure: true })\n```\n\n_Note: Removing a nonexistent cookie neither raises any exception nor returns any value._\n\n## Namespace conflicts\n\nIf there is any danger of a conflict with the namespace `Cookies`, the `noConflict` method will allow you to define a new namespace and preserve the original one. This is especially useful when running the script on third party sites e.g. as part of a widget or SDK.\n\n```javascript\n\u002F\u002F Assign the js-cookie api to a different variable and restore the original \"window.Cookies\"\nvar Cookies2 = Cookies.noConflict()\nCookies2.set('name', 'value')\n```\n\n_Note: The `.noConflict` method is not necessary when using AMD or CommonJS, thus it is not exposed in those environments._\n\n## Encoding\n\nThis project is [RFC 6265](http:\u002F\u002Ftools.ietf.org\u002Fhtml\u002Frfc6265#section-4.1.1) compliant. All special characters that are not allowed in the cookie-name or cookie-value are encoded with each one's UTF-8 Hex equivalent using [percent-encoding](http:\u002F\u002Fen.wikipedia.org\u002Fwiki\u002FPercent-encoding).\nThe only character in cookie-name or cookie-value that is allowed and still encoded is the percent `%` character, it is escaped in order to interpret percent input as literal.\nPlease note that the default encoding\u002Fdecoding strategy is meant to be interoperable [only between cookies that are read\u002Fwritten by js-cookie](https:\u002F\u002Fgithub.com\u002Fjs-cookie\u002Fjs-cookie\u002Fpull\u002F200#discussion_r63270778). To override the default encoding\u002Fdecoding strategy you need to use a [converter](#converters).\n\n_Note: According to [RFC 6265](https:\u002F\u002Ftools.ietf.org\u002Fhtml\u002Frfc6265#section-6.1), your cookies may get deleted if they are too big or there are too many cookies in the same domain, [more details here](https:\u002F\u002Fgithub.com\u002Fjs-cookie\u002Fjs-cookie\u002Fwiki\u002FFrequently-Asked-Questions#why-are-my-cookies-being-deleted)._\n\n## Cookie Attributes\n\nCookie attribute defaults can be set globally by creating an instance of the api via `withAttributes()`, or individually for each call to `Cookies.set(...)` by passing a plain object as the last argument. Per-call attributes override the default attributes.\n\n### expires\n\nDefine when the cookie will be removed. Value must be a [`Number`](https:\u002F\u002Fdeveloper.mozilla.org\u002Fen-US\u002Fdocs\u002FWeb\u002FJavaScript\u002FReference\u002FGlobal_Objects\u002FNumber) which will be interpreted as days from time of creation or a [`Date`](https:\u002F\u002Fdeveloper.mozilla.org\u002Fen-US\u002Fdocs\u002FWeb\u002FJavaScript\u002FReference\u002FGlobal_Objects\u002FDate) instance. If omitted, the cookie becomes a session cookie.\n\nTo create a cookie that expires in less than a day, you can check the [FAQ on the Wiki](https:\u002F\u002Fgithub.com\u002Fjs-cookie\u002Fjs-cookie\u002Fwiki\u002FFrequently-Asked-Questions#expire-cookies-in-less-than-a-day).\n\n**Default:** Cookie is removed when the user closes the browser.\n\n**Examples:**\n\n```javascript\nCookies.set('name', 'value', { expires: 365 })\nCookies.get('name') \u002F\u002F => 'value'\nCookies.remove('name')\n```\n\n### path\n\nA [`String`](https:\u002F\u002Fdeveloper.mozilla.org\u002Fen-US\u002Fdocs\u002FWeb\u002FJavaScript\u002FReference\u002FGlobal_Objects\u002FString) indicating the path where the cookie is visible.\n\n**Default:** `\u002F`\n\n**Examples:**\n\n```javascript\nCookies.set('name', 'value', { path: '' })\nCookies.get('name') \u002F\u002F => 'value'\nCookies.remove('name', { path: '' })\n```\n\n**Note regarding Internet Explorer:**\n\n> Due to an obscure bug in the underlying WinINET InternetGetCookie implementation, IE’s document.cookie will not return a cookie if it was set with a path attribute containing a filename.\n\n(From [Internet Explorer Cookie Internals (FAQ)](http:\u002F\u002Fblogs.msdn.com\u002Fb\u002Fieinternals\u002Farchive\u002F2009\u002F08\u002F20\u002Fwininet-ie-cookie-internals-faq.aspx))\n\nThis means one cannot set a path using `window.location.pathname` in case such pathname contains a filename like so: `\u002Fcheck.html` (or at least, such cookie cannot be read correctly).\n\nIn fact, you should never allow untrusted input to set the cookie attributes or you might be exposed to a [XSS attack](https:\u002F\u002Fgithub.com\u002Fjs-cookie\u002Fjs-cookie\u002Fissues\u002F396).\n\n### domain\n\nA [`String`](https:\u002F\u002Fdeveloper.mozilla.org\u002Fen-US\u002Fdocs\u002FWeb\u002FJavaScript\u002FReference\u002FGlobal_Objects\u002FString) indicating a valid domain where the cookie should be visible. The cookie will also be visible to all subdomains.\n\n**Default:** Cookie is visible only to the domain or subdomain of the page where the cookie was created, except for Internet Explorer (see below).\n\n**Examples:**\n\nAssuming a cookie that is being created on `site.com`:\n\n```javascript\nCookies.set('name', 'value', { domain: 'subdomain.site.com' })\nCookies.get('name') \u002F\u002F => undefined (need to read at 'subdomain.site.com')\n```\n\n**Note regarding Internet Explorer default behavior:**\n\n> Q3: If I don’t specify a DOMAIN attribute (for) a cookie, IE sends it to all nested subdomains anyway?\n> A: Yes, a cookie set on example.com will be sent to sub2.sub1.example.com.\n> Internet Explorer differs from other browsers in this regard.\n\n(From [Internet Explorer Cookie Internals (FAQ)](http:\u002F\u002Fblogs.msdn.com\u002Fb\u002Fieinternals\u002Farchive\u002F2009\u002F08\u002F20\u002Fwininet-ie-cookie-internals-faq.aspx))\n\nThis means that if you omit the `domain` attribute, it will be visible for a subdomain in IE.\n\n### secure\n\nEither `true` or `false`, indicating if the cookie transmission requires a secure protocol (https).\n\n**Default:** No secure protocol requirement.\n\n**Examples:**\n\n```javascript\nCookies.set('name', 'value', { secure: true })\nCookies.get('name') \u002F\u002F => 'value'\nCookies.remove('name')\n```\n\n### partitioned\n\nEither `true` or `false`, indicating if the cookie opts into partitioned storage. Must also set `secure: true`.\n\n**Default:** No partitioned storage.\n\n**Examples:**\n\n```javascript\nCookies.set('name', 'value', { partitioned: true })\nCookies.get('name') \u002F\u002F => 'value'\nCookies.remove('name')\n```\n\n### sameSite\n\nA [`String`](https:\u002F\u002Fdeveloper.mozilla.org\u002Fen-US\u002Fdocs\u002FWeb\u002FJavaScript\u002FReference\u002FGlobal_Objects\u002FString), allowing to control whether the browser is sending a cookie along with cross-site requests.\n\nDefault: not set.\n\n**Note that more recent browsers are making \"Lax\" the default value even without specifying anything here.**\n\n**Examples:**\n\n```javascript\nCookies.set('name', 'value', { sameSite: 'strict' })\nCookies.get('name') \u002F\u002F => 'value'\nCookies.remove('name')\n```\n\n### Setting up defaults\n\n```javascript\nconst api = Cookies.withAttributes({ path: '\u002F', domain: '.example.com' })\n```\n\n## Converters\n\n### Read\n\nCreate a new instance of the api that overrides the default decoding implementation. All get methods that rely in a proper decoding to work, such as `Cookies.get()` and `Cookies.get('name')`, will run the given converter for each cookie. The returned value will be used as the cookie value.\n\nExample from reading one of the cookies that can only be decoded using the `escape` function:\n\n```javascript\ndocument.cookie = 'escaped=%u5317'\ndocument.cookie = 'default=%E5%8C%97'\nvar cookies = Cookies.withConverter({\n  read: function (value, name) {\n    if (name === 'escaped') {\n      return unescape(value)\n    }\n    \u002F\u002F Fall back to default for all other cookies\n    return Cookies.converter.read(value, name)\n  }\n})\ncookies.get('escaped') \u002F\u002F 北\ncookies.get('default') \u002F\u002F 北\ncookies.get() \u002F\u002F { escaped: '北', default: '北' }\n```\n\n### Write\n\nCreate a new instance of the api that overrides the default encoding implementation:\n\n```javascript\nCookies.withConverter({\n  write: function (value, name) {\n    return value.toUpperCase()\n  }\n})\n```\n\n## TypeScript declarations\n\n```bash\nnpm i @types\u002Fjs-cookie\n```\n\n## Server-side integration\n\nCheck out the [Servers Docs](SERVER_SIDE.md)\n\n## Contributing\n\nCheck out the [Contributing Guidelines](CONTRIBUTING.md)\n\n## Releasing\n\nReleasing should be done via the `Release` GitHub Actions workflow, so that published packages on npmjs.com have package provenance.\n\nGitHub releases are created as a draft and need to be published manually!\n(This is so we are able to craft suitable release notes before publishing.)\n\n## Supporters\n\n\u003Cp>\n  \u003Ca href=\"https:\u002F\u002Fwww.browserstack.com\u002F\">\u003Cimg src=\"https:\u002F\u002Fraw.githubusercontent.com\u002Fwiki\u002Fjs-cookie\u002Fjs-cookie\u002FBrowserstack-logo%402x.png\" width=\"150\">\u003C\u002Fa>\n\u003C\u002Fp>\n\nMany thanks to [BrowserStack](https:\u002F\u002Fwww.browserstack.com\u002F) for providing unlimited browser testing free of cost.\n\n## Authors\n\n- [Klaus Hartl](https:\u002F\u002Fgithub.com\u002Fcarhartl)\n- [Fagner Brack](https:\u002F\u002Fgithub.com\u002FFagnerMartinsBrack)\n- And awesome [contributors](https:\u002F\u002Fgithub.com\u002Fjs-cookie\u002Fjs-cookie\u002Fgraphs\u002Fcontributors)\n","js-cookie 是一个轻量级的 JavaScript 库，用于在客户端处理 cookies。它支持广泛的浏览器，接受任何字符，并且经过了大量测试以确保稳定性与可靠性。该库不依赖其他库，同时支持 ES 和 AMD\u002FCommonJS 模块化规范，符合 RFC 6265 标准。其核心功能包括设置、读取及删除 cookie 等操作，且允许自定义编码\u002F解码规则。由于体积小巧（压缩后小于 800 字节），非常适合需要高效管理网站会话状态的应用场景，如用户偏好存储、身份验证等。无论是通过 NPM 安装还是 CDN 引入，都能轻松集成到项目中。",2,"2026-06-11 02:52:24","top_language"]