A remark plugin to automatically convert URLs and email addresses into links.
npm install remark-linkify





A remark plugin to automatically detect URLs and email addresses in text and turn them into Markdown links.
* Automatically converts URLs (like http://example.com) and emails (user@example.com) into links.
* Uses the robust linkify-it library for accurate detection.
* Integrates seamlessly with the remark/unified ecosystem.
* Avoids linkifying text within existing links or code blocks (by default behavior of unist-util-visit).
* Supports ESM and CJS.
``bash`
pnpm add remark-linkify`bash`
yarn add remark-linkify`bash`
npm install remark-linkify
`javascript
import { remark } from 'remark';
import remarkLinkify from 'remark-linkify'; // Note: Default export
const markdownInput =
Visit example.com or contact user@example.com.
Also check https://another.example.org.;
async function processMarkdown() {
const file = await remark()
.use(remarkLinkify)
.process(markdownInput);
console.log(String(file));
/*
Output:
Visit example.com or contact user@example.com.
Also check https://another.example.org.
*/
}
processMarkdown();
`
`jsx
import ReactMarkdown from 'react-markdown';
import remarkLinkify from 'remark-linkify';
import remarkGfm from 'remark-gfm'; // Example other plugin
const markdown = "Go to example.com or email info@example.com.";
function MyComponent() {
return (
>
{markdown}
);
}
export default MyComponent;
`
This plugin currently does not accept any options.
`typescript
import type { Transformer } from 'unified';
import type { Root } from 'mdast';
/**
* A remark plugin to automatically detect URLs and email addresses in text
* and turn them into Markdown links.
*/
declare function remarkLinkify(): Transformer
export default remarkLinkify;
``