Session

Access Receipt

A small session audit strip shown after unlock — timestamp, storage mode, timeout, and verification strategy.

sessionfeedback

Best used for A visible confirmation after unlock — proof for the user (and for you, while testing) of which mode actually ran and how long the session will last.

Requires a <SessionProvider> ancestor — it reports on a session something else already established, it doesn't create one. Pair it with the same config passed to the gate sharing that session, since the receipt can't infer storage mode, timeout, or verification strategy from the session record alone.

Loading preview…
Installation

Add this block to your project

CLI

npx shadcn@latest add http://localhost:3000/r/react/access-receipt.json

Running this site somewhere other than localhost? Set NEXT_PUBLIC_SITE_URL and this command switches to that host automatically.

Also installs

  • Knock Codes Core
  • Knock Codes Types
  • useKnockCodes
  • Session Provider

Files created (8)

  • components/knock-codes/core/hash.ts
  • components/knock-codes/core/verify.ts
  • components/knock-codes/core/session.ts
  • components/knock-codes/core/storage.ts
  • components/knock-codes/react/types.ts
  • components/knock-codes/react/useKnockCodes.ts
  • components/knock-codes/react/KnockCodesProvider.tsx
  • components/knock-codes/react/AccessReceipt.tsx

No CLI? Copy the files by hand

  1. Open the Code tab in the preview above.
  2. Create each path listed below in your project and paste its contents in.
  3. Do the same for anything listed under “Also installs”, if present.

Props

API reference

PropTypeDefaultDescription
storageMode"localStorage" | "sessionStorage" | "memory""localStorage"Storage backend the active session used — shown on the Storage line.
timeoutnumber1800000Session lifetime in milliseconds, formatted on the Timeout line.
verificationStrategy"local-hash" | "server-verify""local-hash"Which verification strategy produced this session.
classNamestringExtra classes on the outer card.
Notes

Accessibility

Read-only summary content — a definition list, not an interactive control. Renders nothing while locked, so it never announces a session that doesn't exist yet.

Customization

Pass `storageMode`, `timeout`, and `verificationStrategy` to match the config given to the `<KnockCodes>`/`useKnockCodes` call sharing this session — the receipt has no way to read those back off the session itself, since the session record intentionally only ever holds `unlockedAt`, `expiresAt`, and an optional token.

Compose with

Blocks that pair well with this one

These combine naturally with this block, whether as a shared shell, a shared session, or a common fallback.