Link

Link

Styled anchor with automatic external link detection — adds open-in-new-tab icon and rel="noopener noreferrer" for external URLs

Installation

npx @ravikumarsurya/mdx-ui add link

Installing link automatically maps it to the a element, so all markdown links get the upgrade.

Usage

Read the getting started guide before installing components.

Source code is available on GitHub.

Once installed, standard markdown link syntax uses the Link component automatically:

[Internal page](/docs/components/callout)
 
[External site](https://react.dev)

External links get target="_blank", rel="noopener noreferrer", and the external icon. Internal links render as normal anchors.

Explicit JSX usage

<Link href="https://github.com">GitHub</Link>
 
<Link href="/docs">Back to docs</Link>

Force external / internal

<Link href="/api/proxy" external>
  Opens in new tab
</Link>
 
<Link href="https://cdn.example.com/file.pdf" external={false}>
  Same tab
</Link>

How external detection works

A URL is treated as external if it starts with http:// or https://. Everything else — relative paths (/docs), hash links (#section), mailto, etc. — is treated as internal.

URLDetected as
https://example.comExternal — icon + new tab
http://example.comExternal — icon + new tab
/docs/introInternal
#sectionInternal
mailto:hi@example.comInternal

Props

PropTypeDefaultDescription
hrefstring""Link destination
externalbooleanauto-detectedOverride external detection
targetstring"_blank" for externalHTML target attribute
relstring"noopener noreferrer" for externalHTML rel attribute
classNamestringExtra classes