Clock Skew

Clock Skew is a copy-paste React component that stops wrong phone clock breaks otp codes 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/clock-skew
Version 0.1.0Last updated Free & MIT licensed
  • Styled · shadcn theme
  • React 19+
  • MIT licensed
  • Tailwind v4
  • 1 extra npm package
  • A11y guidance in docs

StopsWrong phone clock breaks OTP codes

Was this component page useful?

How do I install Clock Skew?

pnpm dlx shadcn@latest add @bollard/clock-skew

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

How do I use Clock Skew in React?

clock-skew-usage.tsx
import { ClockSkew, CorrectedCountdown } from "@/components/ui/clock-skew"

{times ? <CorrectedCountdown to={times.expires} className="font-medium text-foreground" />

What input mistakes does Clock Skew catch?

  • Device clocks ahead of or behind server time beyond a threshold
  • Authenticator codes that will be rejected because of the offset
  • "Expires in" timers that would show the wrong time
  • Clock fixes, by clearing itself when the offset goes away

What props does Clock Skew accept?

ClockSkew props
PropTypeDefault
serverTime

Server time as of now, e.g. rendered into the page by the server. Wins over `measureUrl`.

Date | number | string—
serverTimeUncertainty

How stale `serverTime` may be (network + render time), in ms.

number1000
measureUrl

Same-origin URL to read the Date header from, e.g. "/api/health". Re-checked when the tab is shown again.

string—
threshold

Smallest skew worth warning about, in ms. Default: one 30s TOTP step.

number30_000
onOffsetChange

Called whenever the estimate changes (null until known).

(estimate: ClockOffset | null) => void—
title

Templates: `{skew}` ("4 min 12 s") and `{direction}` ("behind"/"ahead").

string"Your device clock is {skew} {direction}"
otpText

Explains the effect on authenticator codes.

string"Codes from your authenticator app may be rejected."
timersBehindText

Explains timers when the device is behind.

string"Timers elsewhere would show {skew} more than you have. T…
timersAheadText

Explains timers when the device is ahead.

string"Timers elsewhere would show {skew} less than you have. T…
secureSitesText

Explains the effect on secure sites.

string"Secure sites and sign-in links may refuse to work."
fixText

Steps for fixing the device clock.

string"Turn on “Set time automatically” in your device’s date a…
deviceLabel

Label for the device's time.

string"This device"
actualLabel

Label for the actual time.

string"Actual time"
howToFixLabel

Text for the how-to-fix toggle.

string"How to fix"
checkAgainLabel

Text for the check-again button.

string"Check again"
dismissLabel

Text for the dismiss button.

string"Got it"

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

How is Clock Skew accessible?

  • A role="region" with an aria-label from the title
  • The message is aria-live="polite"
  • "How to fix" toggle uses aria-expanded and aria-controls
  • Animation is skipped with prefers-reduced-motion

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

What are the limitations and server boundaries?

  • Accuracy is limited by the Date header's one-second resolution and network round-trip
  • Needs a server time source (prop or a measurable URL)

What expensive mistakes does Clock Skew stop?

Wrong phone clock breaks OTP codes

Also known as

clock skew · device time · totp · authenticator · otp · server time · date header · countdown

Field type

What dependencies does Clock Skew require?

Clock Skew facts & technical specifications

Technical specifications, licensing, and limitations
PropertySpecification
Component nameClock Skew
Registry identifier@bollard/clock-skew
Install commandnpx shadcn@latest add @bollard/clock-skew
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
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 Clock Skew

What form validation mistake does Clock Skew catch?

Clock Skew prevents wrong phone clock breaks OTP codes. Detects when a device clock is off from server time, says what breaks and corrects countdowns, so OTP codes and timers don't fail mysteriously. Catches: Device clocks ahead of or behind server time beyond a threshold, Authenticator codes that will be rejected because of the offset, "Expires in" timers that would show the wrong time, Clock fixes, by clearing itself when the offset goes away. Limitation: validate clock-skew schemas on backend.

How do I install clock-skew with shadcn?

Run `npx shadcn@latest add @bollard/clock-skew`. Sources added: registry/default/clock-skew/clock-skew.tsx, registry/default/clock-skew/skew.ts. Package requirements: lucide-react.

What props customize Clock Skew?

Clock Skew accepts `serverTime`, `serverTimeUncertainty`, `measureUrl`, `threshold`, `onOffsetChange`. Configures clock skew, device time, totp behavior. Limitation: invalid prop values fallback to safe default options.

What are the limits of clock-skew?

Accuracy is limited by the Date header's one-second resolution and network round-trip. Needs a server time source (prop or a measurable URL) Server requirement: backend verification for clock-skew.

How does Clock Skew meet accessibility guidelines?

A role="region" with an aria-label from the title. The message is aria-live="polite". "How to fix" toggle uses aria-expanded and aria-controls. Animation is skipped with prefers-reduced-motion. Minimizes errors: authenticator code not working, device time wrong.

Which components pair with Clock Skew?