unjwt
IntroductionSign and verifyEncrypt and decryptKeysSessionsSafetyDPoP proofsRecipes
  • Recipes
  • Sessions on h3
  • Sessions on Nitro
  • Sessions on Nuxt
  • Sessions on Hono and Workers
  • Use unjwt from a CDN
  • Write a session driver for your framework

Recipes

Whole apps rather than single functions: one session flow on each framework, with the key, the routes and what goes wrong.

Every session recipe builds the same three routes, so you can put two frameworks side by side and see only what differs. POST /login takes { "user": "…" } and starts a session, GET /me answers with the session's data or a 401, and POST /logout ends it. Each recipe then adds the one thing its framework does its own way. The session itself is a signed cookie; the Sessions section explains every option the recipes leave at its default.

Sessions on h3

An h3 app that hands its event to the session as it is, plus a middleware that guards a group of routes.

Sessions on Nitro

A server util keyed from the runtime config, one file per route, and a WebSocket that reads the session at the upgrade.

Sessions on Nuxt

server/utils/session.ts, routes on nuxt/server, and an app.vue that calls them.

Sessions on Hono and Workers

A Hono middleware on Cloudflare Workers, with the key from the Worker's secrets.

Use unjwt from a CDN

A plain HTML page that verifies a pasted token in the browser, pinned to one release.

Write a session driver

Sessions on a framework unjwt doesn't know, shown with Express's req and res.

Edit this page
Previous DPoP proofs Next Sessions on h3

unjwt  JSON Web Tokens on the Web Crypto API.