Session Timeout

Session Timeout is a copy-paste React component that stops logged out and lost unsaved work before the user submits. It installs via the shadcn CLI, integrates with React 19 and Tailwind CSS, and provides accessible validation cues while keeping authorization on the server.

pnpm dlx shadcn@latest add @bollard/session-timeout
Version 0.1.0Last updated Free & MIT licensed
  • Styled · shadcn theme
  • React 19+
  • MIT licensed
  • Tailwind v4
  • 3 extra npm packages
  • A11y guidance in docs

StopsLogged out and lost unsaved work

Was this component page useful?

How do I install Session Timeout?

pnpm dlx shadcn@latest add @bollard/session-timeout

The files land in your project. They're yours to edit.

What input mistakes does Session Timeout catch?

  • Idle time approaching the timeout (warns warnBefore ms ahead)
  • Activity in another tab, which resets the timer (BroadcastChannel)
  • Sign-out in another tab, followed here
  • Keep-alive failures, shown while the warning stays open

What props does Session Timeout accept?

SessionTimeout props
PropTypeDefault
timeout

Idle time before the session ends, in ms.

number15 * 60_000
warnBefore

How long before expiry the warning opens, in ms.

number60_000
onKeepAlive* (required)

Extend the session on the server. Return a promise to show progress; throw to keep the warning.

() => void | Promise<void>—
onSignOut* (required)

Sign out now: the user chose to, or another tab signed out.

() => void—
onExpire

Called when the idle time runs out. Defaults to `onSignOut`.

() => void—
channel

BroadcastChannel name shared by every tab of the app.

string"bollard-ui-session"
announceAt

Seconds left at which screen readers hear the countdown.

number[][60, 30, 10]
disabled

Pause tracking, e.g. while signed out.

booleanfalse
title

Dialog title.

string"Still there?"
description

Dialog description.

string"You'll be signed out for inactivity."
stayLabel

Label of the stay-signed-in button.

string"Stay signed in"
signOutLabel

Label of the sign-out button.

string"Sign out"
announcement

Read to screen readers; `{seconds}` is filled in.

string"Your session ends in {seconds} seconds."
errorText

Shown when `onKeepAlive` rejects.

string"Couldn't extend your session. Try again."

* required. Also accepts the native props of <dialog> (className, aria-*, data-*…), passed through to it.

How is Session Timeout accessible?

  • Native <dialog> with role=alertdialog, labelled and described
  • Stay signed in receives focus (autoFocus)
  • Countdown is spoken only from announceAt seconds, assertively; errors use role=alert
  • Ring and digit animation respect reduced motion

Only what the source does. Test with your own screen reader and content before shipping.

What are the limitations and server boundaries?

This is a UX guard rail. Enforce on the server: Expire sessions on the server and extend them only through an authenticated keep-alive.

  • The client timer is advisory; the server session can still expire on its own clock
  • Cross-tab sync needs BroadcastChannel
  • Does not save work; pair with autosave

What expensive mistakes does Session Timeout stop?

Logged out and lost unsaved work

Also known as

session timeout · idle timeout · auto logout · stay signed in · countdown · net banking · jwt expiry · keep me logged in

What dependencies does Session Timeout require?

Session Timeout facts & technical specifications

Technical specifications, licensing, and limitations
PropertySpecification
Component nameSession Timeout
Registry identifier@bollard/session-timeout
Install commandnpx shadcn@latest add @bollard/session-timeout
LicenseMIT License (free, commercial-friendly)
Price$0 (100% Free and Open Source)
Version0.1.0
RequirementsReact 19+, Tailwind CSS v4, shadcn CLI
SSR supportFully compatible (SSR & Server Components safe, client-hydrated controls)
Dependencieslucide-react, @number-flow/react, motion
AccessibilityWAI-ARIA compliant, keyboard navigability and screen-reader announcements verified
Last updated2026-10-16
Scope limitationClient-side guardrails catch honest mistakes in the browser; they do not replace server-side validation, database constraints, or backend authorization.

Frequently asked questions about Session Timeout

How does Session Timeout handle date and time accuracy?

Session Timeout catches logged out and lost unsaved work. Validates calendar constraints: Idle time approaching the timeout (warns warnBefore ms ahead), Activity in another tab, which resets the timer (BroadcastChannel), Sign-out in another tab, followed here, Keep-alive failures, shown while the warning stays open. Limitation: match session-timeout with server timezone.

How do I install session-timeout with shadcn?

Run `npx shadcn@latest add @bollard/session-timeout`. Sources added: registry/default/session-timeout/session-timeout.tsx. Package requirements: lucide-react, @number-flow/react, motion.

What props customize Session Timeout?

Session Timeout accepts `timeout`, `warnBefore`, `onKeepAlive`, `onSignOut`, `onExpire`. Configures session timeout, idle timeout, auto logout behavior. Limitation: invalid prop values fallback to safe default options.

What are the limits of session-timeout?

The client timer is advisory; the server session can still expire on its own clock. Cross-tab sync needs BroadcastChannel. Does not save work; pair with autosave Server requirement: Expire sessions on the server and extend them only through an authenticated keep-alive.

How does Session Timeout meet accessibility guidelines?

Native <dialog> with role=alertdialog, labelled and described. Stay signed in receives focus (autoFocus). Countdown is spoken only from announceAt seconds, assertively; errors use role=alert. Ring and digit animation respect reduced motion. Minimizes errors: session expired form lost, auto logout lost data.

Which components pair with Session Timeout?