Key Rotate

Key Rotate is a copy-paste React component that stops helps prevent a key rotation taking production down 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/key-rotate
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

StopsHelps prevent a key rotation taking production down

Was this component page useful?

How do I install Key Rotate?

pnpm dlx shadcn@latest add @bollard/key-rotate

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

How do I use Key Rotate in React?

key-rotate-usage.tsx
import { KeyRotate, type KeyClient } from "@/components/ui/key-rotate"

<KeyRotate
  key={run}
  keyName="production secret key"
  clients={clients}
  defaultValue={0}
  rotatedAt={rotatedAt}
  onRotate={(overlap) => wait(() => (overlap ? setRotatedAt(Date.now()) : setDone("Old key expired. Clients still using it now get 401 errors until they're updated.")))}
  onRevokeOld={() => wait(() => setDone("Old key revoked."))}
/>

What input mistakes does Key Rotate catch?

  • Clients still calling with the old key
  • Rare jobs whose next call lands after the old key expires
  • Immediate revoke while the old key is still in use
  • Leaked key: allows an immediate cut-off on purpose

What props does Key Rotate accept?

KeyRotate props
PropTypeDefault
keyName* (required)

e.g. "Production secret key".

string—
clients* (required)

Who calls with this key and when they last did.

KeyClient[]—
value

Overlap window in ms (0 = the old key stops working immediately). Controlled.

number—
defaultValue

Initial overlap window in ms when uncontrolled.

number86_400_000
onValueChange

Called with the chosen overlap window in ms.

(overlap: number) => void—
options

Windows to offer, in ms.

number[][0, 3_600_000, 86_400_000, 604_800_000]
rotatedAt

When the new key was issued. Set it once rotation has started to show the overlap phase.

When—
quietFor

The old key must go unused this long (ms) before it can be cut off immediately.

number3_600_000
onRotate* (required)

Starts the rotation with the chosen window. A returned promise shows a pending state; a rejection is caught.

(overlap: number) => void | Promise<void>—
onRevokeOld

Revokes the old key during the overlap.

() => void | Promise<void>—
locale

BCP 47 locale for dates and times. Defaults to the viewer's.

string—
messages

Every visible string (see `KEY_ROTATE_MESSAGES`). The single-string props below still work and win.

Partial<KeyRotateMessages>—
optionLabel(overlap: number) => string—
rotateLabel(overlap: number) => string—
revokeLabelstring—
leakedLabelstring—
extendLabel(overlap: number) => string—

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

How is Key Rotate accessible?

  • Panel labelled by its title; overlap options are native radio inputs with labels
  • Client status list and warnings are polite live regions with text, not only icons
  • A blocked revoke is announced with role=alert

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: Enforce key expiry and revocation in the key service, and log last-used times per key so the client list is real.

  • Only knows the clients and last-seen times you pass
  • Rhythm-based predictions assume jobs keep their schedule
  • The overlap window is enforced by your key service, not this UI

What expensive mistakes does Key Rotate stop?

Helps prevent a key rotation taking production down

Also known as

api key · rotate key · secret rotation · credentials · revoke key · access token · env vars · webhook secret

Field type

What dependencies does Key Rotate require?

Key Rotate facts & technical specifications

Technical specifications, licensing, and limitations
PropertySpecification
Component nameKey Rotate
Registry identifier@bollard/key-rotate
Install commandnpx shadcn@latest add @bollard/key-rotate
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 Key Rotate

How does Key Rotate protect destructive mutations?

Key Rotate prevents a key rotation taking production down. Enforces deliberate friction against Clients still calling with the old key, Rare jobs whose next call lands after the old key expires, Immediate revoke while the old key is still in use, Leaked key: allows an immediate cut-off on purpose. Limitation: authorize key-rotate mutations on the server.

How do I install key-rotate with shadcn?

Run `npx shadcn@latest add @bollard/key-rotate`. Sources added: registry/default/key-rotate/key-rotate.tsx. Package requirements: lucide-react.

What props customize Key Rotate?

Key Rotate accepts `keyName`, `clients`, `value`, `defaultValue`, `onValueChange`. Configures api key, rotate key, secret rotation behavior. Limitation: invalid prop values fallback to safe default options.

What are the limits of key-rotate?

Only knows the clients and last-seen times you pass. Rhythm-based predictions assume jobs keep their schedule. The overlap window is enforced by your key service, not this UI Server requirement: Enforce key expiry and revocation in the key service, and log last-used times per key so the client list is real.

How does Key Rotate meet accessibility guidelines?

Panel labelled by its title; overlap options are native radio inputs with labels. Client status list and warnings are polite live regions with text, not only icons. A blocked revoke is announced with role=alert. Minimizes errors: rotated api key broke prod, old key revoked too early.

Which components pair with Key Rotate?