{"id":31785156,"url":"https://github.com/namesmt/hono-cookie-state","last_synced_at":"2025-10-10T11:44:21.429Z","repository":{"id":318520176,"uuid":"1071628940","full_name":"NamesMT/hono-cookie-state","owner":"NamesMT","description":null,"archived":false,"fork":false,"pushed_at":"2025-10-07T16:17:05.000Z","size":76,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-10-07T18:29:34.026Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","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/NamesMT.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,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-10-07T15:45:38.000Z","updated_at":"2025-10-07T16:17:09.000Z","dependencies_parsed_at":"2025-10-07T18:31:22.269Z","dependency_job_id":"89df4feb-83d5-4121-86cd-43343583e7c5","html_url":"https://github.com/NamesMT/hono-cookie-state","commit_stats":null,"previous_names":["namesmt/hono-cookie-state"],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/NamesMT/hono-cookie-state","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NamesMT%2Fhono-cookie-state","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NamesMT%2Fhono-cookie-state/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NamesMT%2Fhono-cookie-state/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NamesMT%2Fhono-cookie-state/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/NamesMT","download_url":"https://codeload.github.com/NamesMT/hono-cookie-state/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NamesMT%2Fhono-cookie-state/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279003715,"owners_count":26083610,"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","status":"online","status_checked_at":"2025-10-10T02:00:06.843Z","response_time":62,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":[],"created_at":"2025-10-10T11:44:16.335Z","updated_at":"2025-10-10T11:44:21.422Z","avatar_url":"https://github.com/NamesMT.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cdiv align=\"center\"\u003e\n\n\u003ch1\u003eHono Cookie State\u003c/h1\u003e\n\n\u003c/div\u003e\n\n# hono-cookie-state ![TypeScript heart icon](https://img.shields.io/badge/♡-%23007ACC.svg?logo=typescript\u0026logoColor=white)\n\n[![npm version][npm-version-src]][npm-version-href]\n[![npm downloads][npm-downloads-src]][npm-downloads-href]\n[![Codecov][codecov-src]][codecov-href]\n[![Bundlejs][bundlejs-src]][bundlejs-href]\n[![TypeDoc][TypeDoc-src]][TypeDoc-href]\n\n* [hono-cookie-state ](#hono-cookie-state-)\n  * [Overview](#overview)\n  * [Features](#features)\n  * [Usage](#usage)\n    * [Install package](#install-package)\n    * [Import and use](#import-and-use)\n  * [Roadmap](#roadmap)\n  * [Credits and Notes](#credits-and-notes)\n  * [License](#license)\n\n## Overview\n\n**hono-cookie-state** is a simple library to persist data / states in cookies for Hono, securely (via [`iron-webcrypto`](https://github.com/brc-dd/iron-webcrypto)) and with type-safety.\n\n## Features\n\n+ 👌 TypeScript\n\n## Usage\n\n### Install package\n\n```sh\n# npm\nnpm install -D hono-cookie-state\n\n# bun\nbun add -D hono-cookie-state\n\n# pnpm\npnpm install -D hono-cookie-state\n```\n\n### Import and use\n\n```ts\nimport type { CookieState } from 'hono-cookie-state'\nimport { createCookieState } from 'hono-cookie-state'\n\n// Usage is as simple .use() the created middleware, and just update the state's data, the cookie will automatically be updated when the data has changed, or is near expiration with `autoRefreshSession=true` (default)\nconst app = new Hono()\n  .use(createCookieState({\n    key: 'hiWorld',\n    secret: 'password_at_least_32_characters!',\n    cookieOptions: {\n      maxAge: 90 * 60, // 90 mins\n      sameSite: 'None',\n      secure: true,\n      path: '/',\n      httpOnly: true,\n    },\n  }))\n  // For simple usage, variable type is automatically populated to context chain\n  .get('/sample', async (c) =\u003e {\n    const state = c.var.hiWorld // is of type CookieState\u003cany\u003e\n    state.data.hi = 'world'\n  })\n\n// For more complex usage, you can populate Hono's init Env:\nconst app = new Hono\u003c{ Variables: { hiWorld: CookieState\u003c{ hello: string }\u003e } }\u003e()\n// Or pass the data type into createCookieState, note you need to also pass the key as the second generic, due to TS limitation:\ncreateCookieState\u003c{ hello: string }, 'hiWorld'\u003e({\n  key: 'hiWorld',\n  secret: 'password_at_least_32_characters!',\n})\n```\n\n## Roadmap\n\n- Chunked cookie support\n  - Awaits [honojs/hono#4447](https://github.com/honojs/hono/issues/4447)\n\n## Credits and Notes\n\nThis package copies the inline, rewritten [`iron-crypto.ts`](https://github.com/brc-dd/iron-webcrypto) and base64url `encoding.ts` from [h3](https://github.com/h3js/h3)\n\n## License\n\n[![License][license-src]][license-href]\n\n\u003c!-- Badges --\u003e\n\n[npm-version-src]: https://img.shields.io/npm/v/hono-cookie-state?labelColor=18181B\u0026color=F0DB4F\n[npm-version-href]: https://npmjs.com/package/hono-cookie-state\n[npm-downloads-src]: https://img.shields.io/npm/dm/hono-cookie-state?labelColor=18181B\u0026color=F0DB4F\n[npm-downloads-href]: https://npmjs.com/package/hono-cookie-state\n[codecov-src]: https://img.shields.io/codecov/c/gh/namesmt/hono-cookie-state/main?labelColor=18181B\u0026color=F0DB4F\n[codecov-href]: https://codecov.io/gh/namesmt/hono-cookie-state\n[license-src]: https://img.shields.io/github/license/namesmt/hono-cookie-state.svg?labelColor=18181B\u0026color=F0DB4F\n[license-href]: https://github.com/namesmt/hono-cookie-state/blob/main/LICENSE\n[bundlejs-src]: https://img.shields.io/bundlejs/size/hono-cookie-state?labelColor=18181B\u0026color=F0DB4F\n[bundlejs-href]: https://bundlejs.com/?q=hono-cookie-state\n[jsDocs-src]: https://img.shields.io/badge/Check_out-jsDocs.io---?labelColor=18181B\u0026color=F0DB4F\n[jsDocs-href]: https://www.jsdocs.io/package/hono-cookie-state\n[TypeDoc-src]: https://img.shields.io/badge/Check_out-TypeDoc---?labelColor=18181B\u0026color=F0DB4F\n[TypeDoc-href]: https://namesmt.github.io/hono-cookie-state/\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnamesmt%2Fhono-cookie-state","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnamesmt%2Fhono-cookie-state","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnamesmt%2Fhono-cookie-state/lists"}