Skip to content
Eskais UI

Data

Expiry Countdown

ExpiryCountdown and useExpiry: the time left until a code or request expires in a role="timer", shown each second and announced politely once a minute and at 30, 20 and 10 seconds, with one timeout per second while the page is visible and none while it's hidden; useExpiry runs a callback once when the time passes.

Example

Link expires in 1:15

Installation

npx shadcn@latest add @eskais/expiry-countdown

Usage

Import
import { announcementStep, useCountdownAnnouncements, useExpiry, useSecondsLeft } from "@/components/ui/use-expiry"import { ExpiryCountdown, formatRemaining } from "@/components/ui/expiry-countdown"

The time left until a code, link or request expires: ExpiryCountdown shows it each second, and useExpiry tells you once it has passed. DeviceApproval and DeviceCodePrompt use both.

API reference

ExpiryCountdown

PropTypeDefault
expiresAtrequiredWhen it expires, in epoch milliseconds.number–
expiresInrequiredExpiresInText–
classNamestring–
data-slotstring–

Other exports

announcementStepuseCountdownAnnouncementsuseExpiryuseSecondsLeftformatRemainingtype ExpiresInTexttype ExpiryCountdownProps

Accessibility

  • A timer that isn't live: the time left is announced politely once a minute and at 30, 20 and 10 seconds, never on the first render.
  • One timeout per second while the page is visible and none while it's hidden; showing the page again checks the clock.

Agent actions

Runs agent.snapshot() from @ui-sdk/react/agent on the live preview above.