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
expiry-countdown-demo.tsxCopy code
Installation
Copy code
Usage
ImportCopy code
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
| Prop | Type | Default |
|---|---|---|
expiresAtrequiredWhen it expires, in epoch milliseconds. | number | – |
expiresInrequired | ExpiresInText | – |
className | string | – |
data-slot | string | – |
Other exports
announcementStepuseCountdownAnnouncementsuseExpiryuseSecondsLeftformatRemainingtype ExpiresInTexttype ExpiryCountdownPropsAccessibility
- 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.