{"id":13447306,"url":"https://github.com/alik0211/hardtack","last_synced_at":"2025-08-21T08:30:42.261Z","repository":{"id":33491429,"uuid":"157241080","full_name":"alik0211/hardtack","owner":"alik0211","description":"An ultra-light (373 bytes) library for working with cookies in JavaScript","archived":false,"fork":false,"pushed_at":"2023-07-12T07:18:20.000Z","size":3108,"stargazers_count":63,"open_issues_count":20,"forks_count":3,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-12-11T15:47:07.704Z","etag":null,"topics":["browser","cookie","cookies","front-end","javascript","js-cookie","ultra-light"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/hardtack","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/alik0211.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-11-12T16:14:21.000Z","updated_at":"2022-03-23T02:20:14.000Z","dependencies_parsed_at":"2024-06-18T20:12:36.696Z","dependency_job_id":"1de0d616-3baa-4409-a93b-c813d6383c54","html_url":"https://github.com/alik0211/hardtack","commit_stats":{"total_commits":99,"total_committers":2,"mean_commits":49.5,"dds":"0.010101010101010055","last_synced_commit":"f814e67bd74d4ec21b9a46b759d71352e20a71d4"},"previous_names":[],"tags_count":12,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alik0211%2Fhardtack","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alik0211%2Fhardtack/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alik0211%2Fhardtack/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alik0211%2Fhardtack/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/alik0211","download_url":"https://codeload.github.com/alik0211/hardtack/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":230052720,"owners_count":18165418,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["browser","cookie","cookies","front-end","javascript","js-cookie","ultra-light"],"created_at":"2024-07-31T05:01:13.440Z","updated_at":"2024-12-19T21:09:44.588Z","avatar_url":"https://github.com/alik0211.png","language":"JavaScript","funding_links":[],"categories":["JavaScript"],"sub_categories":[],"readme":"# hardtack\n\n[![NPM](https://img.shields.io/npm/v/hardtack.svg?style=flat-square)](https://www.npmjs.com/package/hardtack)\n[![GitHub Actions](https://img.shields.io/github/workflow/status/alik0211/hardtack/Unit%20tests/master?style=flat-square)](https://github.com/alik0211/hardtack/actions?query=branch%3Amaster)\n[![Coverage Status](https://img.shields.io/coveralls/github/alik0211/hardtack/master.svg?style=flat-square)](https://coveralls.io/github/alik0211/hardtack?branch=master)\n\n\u003e An ultra-light library for working with cookies in JavaScript.\n\n## Features\n\n- Simple API\n- Ultra-light (**373 bytes** minified and gzipped). No dependencies. [Size Limit](https://github.com/ai/size-limit) controls the size.\n- Encoding of forbidden characters\n- Load only the necessary method\n\n## Table of contents\n\n- [Quick start](#quick-start)\n  - [Installation](#installation)\n  - [Usage](#usage)\n- [Methods](#methods)\n  - [set(name: string, value: string, options)](#setname-string-value-string-options)\n    - [options.path: string](#optionspath-string)\n    - [options.domain: string](#optionsdomain-string)\n    - [options.maxAge: number](#optionsmaxage-number)\n    - [options.expires: string](#optionsexpires-string)\n    - [options.secure: boolean](#optionssecure-boolean)\n    - [options.samesite: string](#optionssamesite-string)\n  - [get(name: string)](#getname-string)\n  - [remove(name: string, options)](#removename-string-options)\n\n## Quick start\n\n### Installation\n```sh\nyarn add hardtack -E\n# or\nnpm i hardtack -E\n```\n\n### Usage\n```javascript\n// Load the full library\nimport hardtack from 'hardtack';\n// Load the necessary method\nimport get from 'hardtack/src/get';\nimport set from 'hardtack/src/set';\nimport remove from 'hardtack/src/remove';\n\nhardtack.set('name', 'Ali', {\n  path: '/',\n  domain: 'gasymov.com',\n  maxAge: 31536000, // 1 year\n  samesite: 'lax'\n});\n\nhardtack.get(); // { name: 'Ali' };\n\nhardtack.get('name'); // Ali;\n\nhardtack.remove('name', {\n  path: '/',\n  domain: 'gasymov.com'\n});\n```\n\n## Methods\n### `set(name: string, value: string, options)`\n\nCreate a cookie\n\n#### options.path: string\n\nFor example: `'/'`, `'/mydir'`\n\nIf not specified, defaults to the current path of the current document location.\n\n#### options.domain: string\n\nFor example: `example.com` or `subdomain.example.com`\n\nIf not specified, this defaults to the host portion of the current document location. Contrary to earlier specifications, leading dots in domain names are ignored, but browsers may decline to set the cookie containing such dots. If a domain is specified, subdomains are always included.\n\n#### options.maxAge: number\n\nYou can use `options['max-age']`, the result will be the same.\n\nMax age in seconds. For example: `60*60*24*365` or `31536000` for a year\n\n#### options.expires: string\n\nDate in GMT format. See [Date.toUTCString()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toUTCString) for help formatting this value.\n\n#### options.secure: boolean\n\nCookie to only be transmitted over secure protocol as https.\n\n#### options.samesite: string\n\nSameSite prevents the browser from sending this cookie along with cross-site requests. Possible values for the flag are `lax` or `strict`.\n\nMore about the options of cookies on [MDN](https://developer.mozilla.org/en-US/docs/Web/API/Document/cookie).\n\n### `get(name: string)`\n\nGet cookie value\n\n### `remove(name: string, options)`\n\nRemove cookie. When you delete a cookie, you **must** pass the same `options.path` and `options.domain` that you passed when you created the cookie.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falik0211%2Fhardtack","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Falik0211%2Fhardtack","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falik0211%2Fhardtack/lists"}