{"id":23248239,"url":"https://github.com/devhammed/use-cookie","last_synced_at":"2025-10-26T01:45:25.941Z","repository":{"id":57107904,"uuid":"183489474","full_name":"devhammed/use-cookie","owner":"devhammed","description":"Get, Set, Update and Delete Cookie using React Hooks.","archived":false,"fork":false,"pushed_at":"2024-04-23T02:04:59.000Z","size":1271,"stargazers_count":17,"open_issues_count":2,"forks_count":2,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-11-29T13:20:14.240Z","etag":null,"topics":["cookie","react","react-hooks"],"latest_commit_sha":null,"homepage":"https://hammed.dev/use-cookie/","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/devhammed.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-04-25T18:31:49.000Z","updated_at":"2024-05-24T08:49:36.000Z","dependencies_parsed_at":"2022-08-20T17:11:17.399Z","dependency_job_id":null,"html_url":"https://github.com/devhammed/use-cookie","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/devhammed%2Fuse-cookie","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/devhammed%2Fuse-cookie/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/devhammed%2Fuse-cookie/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/devhammed%2Fuse-cookie/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/devhammed","download_url":"https://codeload.github.com/devhammed/use-cookie/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":230400628,"owners_count":18219832,"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":["cookie","react","react-hooks"],"created_at":"2024-12-19T08:12:56.641Z","updated_at":"2025-10-26T01:45:20.890Z","avatar_url":"https://github.com/devhammed.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# @devhammed/use-cookie\n\n\u003e Get, Set, Update and Delete Cookie using React Hooks.\n\n[![NPM](https://img.shields.io/npm/v/@devhammed/use-cookie.svg)](https://www.npmjs.com/package/@devhammed/use-cookie) [![JavaScript Style Guide](https://img.shields.io/badge/code_style-standard-brightgreen.svg)](https://standardjs.com) [![Made in Nigeria](https://img.shields.io/badge/made%20in-nigeria-008751.svg?style=flat-square)](https://github.com/acekyd/made-in-nigeria)\n\n## Install\n\n```bash\nnpm install --save @devhammed/use-cookie\n```\n\n## Usage\n\n```tsx\nimport React from 'react'\nimport ReactDOM from 'react-dom'\nimport useCookie from '@devhammed/use-cookie'\n\nconst App = () =\u003e {\n  const [username, setUsername, deleteUsername] = useCookie('username', 'User')\n  return (\n    \u003csection\u003e\n      \u003ch1\u003eHello {username}!\u003c/h1\u003e\n      \u003cp\u003eEdit below input, Your name will be stored in a cookie. you can refresh this page to see how it persists.\u003c/p\u003e\n      \u003cinput\n        type='text'\n        value={username}\n        onChange={(e) =\u003e setUsername(e.target.value)}\n      /\u003e\n      \u003cbutton\n        onClick={() =\u003e deleteUsername()}\n      \u003e\n        Delete Cookie\n      \u003c/button\u003e\n    \u003c/section\u003e\n  )\n}\n\nReactDOM.render(\u003cApp /\u003e, document.getElementById('root'))\n```\n[View Demo](https://devhammed.github.io/use-cookie)\n\n## API\n```tsx\n  // Using the Hook\n  useCookie(key: string, defaultValue?: any): [any, (value: any, options?: object) =\u003e void, () =\u003e void]\n\n  // Setting Example\n  // Array or Object passed to the function will be turned into JSON.\n  // Options and the keys are optionally and below are the default options:\n  const options = {\n    expires: 0,\n    domain: '',\n    path: '',\n    secure: false,\n    httpOnly: false,\n    maxAge: 0,\n    sameSite: ''\n  }\n  setCookie(value: any, options?: object)\n\n  // Delete Example\n  deleteCookie()\n```\n\nuseCookie() hook returns an array containing three items. The first item is the cookie value,\nthe second item is the function to update the cookie and the third item is the function to delete the cookie.\n\n## License\n\nMIT © [devHammed](https://github.com/devHammed)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdevhammed%2Fuse-cookie","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdevhammed%2Fuse-cookie","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdevhammed%2Fuse-cookie/lists"}