Hono-session is a cookie-based session middleware for the Hono web framework. Offers both stateless (encrypted cookie) and external storage modes. The current stable version is 1.2.0, with frequent updates. Features session renewal, regeneration for preventing fixation attacks, flash messages, and reflash ability. Supports custom encryption via iron-webcrypto and stores like Map, file, or database. Built in TypeScript with global type augmentation. Requires Node.js >=18.18.0. Alternatives like @hono/sessions exist but hono-session is lighter and simpler.
npm install hono-sessionNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Basic setup with login and user retrieval using stateless encrypted cookies.
Remove the extra function call: use `app.use(session({...}))` instead of `app.use(session()({...}))`Avoid using `existsCookieName`. If you need a presence cookie, set it manually.
Ensure secret is >=32 characters, or omit it for random secret (but sessions won't survive restart).
Always include `c` parameter in store methods (even if unused) to maintain consistency.
Add `import 'hono-session/global'` at top of the file or tsconfig include.
Ensure iron-webcrypto is installed and at version ^6.0.0. If using ESM, add `"type": "module"` to package.json.
Provide a secret of at least 32 characters, or remove secret option to use auto-generated (sessions lost on restart).
Import 'hono-session/global' at top of file and ensure tsconfig includes the file. Alternatively use `c.get('session')`.Upgrade to v1.0.0 or later. If on older version, use `import 'hono-session/types'` instead.