Session

Session Timeout Banner

Warns before the shared session expires, with a one-click way to log out immediately.

sessionfeedback

Best used for Warning users before a shared session expires, especially with a short or activity-based timeout.

Requires a <SessionProvider> ancestor — it watches a session something else already established, it doesn't create one.

Loading preview…
Installation

Add this block to your project

CLI

npx shadcn@latest add http://localhost:3000/r/react/session-timeout-banner.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/SessionTimeoutBanner.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
warnBeforeMsnumber60000Show the banner once this many ms remain before expiry.
classNamestringExtra classes on the banner.
Notes

Accessibility

role="alert" — announced immediately when it appears, not just on next poll of an aria-live region, since an imminent session expiry is time-sensitive.

Customization

Renders nothing outside the warning window or with no active session, so it's safe to mount unconditionally near the top of a layout. Adjust `warnBeforeMs` to change how early it appears.

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.