Email Change Guard

Catches typos in a new account email and keeps the old address active until the new one is verified, so nobody locks themselves out.

StopsLocked out by a typo'd new email

Installation

pnpm dlx shadcn@latest add https://bollard-ui.vercel.app/r/email-change-guard.json

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

Usage

email-change-guard-usage.tsx
import { EmailChangeGuard } from "@/components/ui/email-change-guard"

<EmailChangeGuard
  currentEmail="tushar.k@outlook.com"
  defaultValue="tushar.khadde@gmial.con"
  onRequestChange={() => wait(700)}
  onResend={() => wait(400)}
  onCancelChange={() => wait(300)}
/>

What it catches

  • Misspelled email providers, with a one-tap fix
  • The exact point where the confirmation stops matching
  • A "new" address that is the same inbox (Gmail dots, +tags)
  • What moves with the address: sign-in, receipts and 2FA codes

Props

EmailChangeGuard props
PropTypeDefault
currentEmail* (required)

The account's current, verified email.

string—
value

Controlled new-email text.

string—
defaultValue

Initial new-email text when uncontrolled.

string""
onValueChange

Called as the new email is typed or fixed.

(email: string) => void—
pendingEmail

Controlled address awaiting verification; null for none.

string | null—
onRequestChange

Sends the verification link. Only called for a clean, matching address. May return a Promise; a rejection keeps the form.

(email: string) => void | Promise<void>—
onResend

Sends the link again.

(email: string) => void | Promise<void>—
onCancelChange

Drops the pending change; the current email stays.

(email: string) => void | Promise<void>—
resendCooldown

Seconds before Resend is allowed again.

number30
domains

Provider domains to check typos against.

string[]—
delay

Pause in ms before typo and match checks run while typing.

number600
messages

Any visible string.

Partial<EmailChangeMessages>—

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

Accessibility

  • Focus moves to the confirmation field, the fix, or the pending notice as the flow advances
  • Fields are described by their hints via aria-describedby
  • The pending state has a focusable heading

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

Limitations

This is a UX guard rail. Enforce on the server: Keep the old address active until the new one is verified, notify the old address of the change, and rate-limit resends on the server.

  • Domain typo detection uses a list of known providers; custom domains aren't checked
  • Keeping the old address active depends on your backend honouring the pending state

What it stops

Locked out by a typo'd new email

Also known as

change email · update email · account settings · profile · email verification · confirm email · login email · 2fa

Field type

Dependencies

Pairs well with