External Link

Confirms off-site links with the real destination and flags lookalike, punycode or mismatched links, so people don't click through to a phishing site.

StopsClicked through to a phishing site

Installation

pnpm dlx shadcn@latest add https://bollard-ui.vercel.app/r/external-link.json

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

Usage

external-link-usage.tsx
import { ExternalLink } from "@/components/ui/external-link"

<ExternalLink href={link.href} confirm={link.confirm}>
  {link.text}
</ExternalLink>

What it catches

  • Punycode and lookalike domains
  • Link text that names a different site than the href
  • Brand names buried in subdomains (paypal.com.example.net)
  • Raw IP addresses and plain http://

Props

ExternalLink props
PropTypeDefault
href* (required)

Absolute destination URL. Same-host links render as plain links.

string—
trustedDomains

Domains people are likely to be impersonating, used for lookalike checks.

string[]DEFAULT_TRUSTED
confirm

When to stop and show the destination. "always" confirms every external link; "risky" lets clean links through untouched and only stops for ones with a warning, so trusted content (docs, your own footer) never nags.

"always" | "risky""always"
labels

Override any label.

Partial<typeof EXTERNAL_LINK_LABELS>—
warningMessages

Override any warning sentence (see `LINK_WARNING_MESSAGES`).

Partial<Record<LinkIssue["kind"], string>>—

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

Accessibility

  • Links that confirm expose aria-haspopup="dialog" and aria-expanded
  • The confirmation is role="dialog" labelled by its title; Escape closes it and returns focus to the link
  • Warnings are written in text

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

Limitations

  • Heuristics only: a well-made phishing domain with no lookalike signals passes
  • Registrable-domain detection uses a built-in suffix list that may miss newer suffixes
  • Trusted domains are whatever you pass

What it stops

Clicked through to a phishing site

Also known as

external link · phishing · leaving site · punycode · url · link warning · safe browsing · redirect

Field type

Dependencies

Pairs well with