Security News
Fluent Assertions Faces Backlash After Abandoning Open Source Licensing
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.
react-linkify-it
Advanced tools
A tiny and dependency free universal linking solution that turns any pattern in your text into clickable links (aka linkify). Supports i18n and emojis.
A tiny and dependency free universal linking solution that turns any pattern in your text into clickable links (aka linkify). Supports i18n and emojis.
react-linkify-it
comes with a set of prebuilt components for specific linking needs and a generic component to wrap any pattern with a component.
Prebuilt components for linking:
You can also use the generic component which lets you support your own use case as desired:
react-linkify-it
provides a modern bundle for actively maintained browsers and a larger legacy bundle for older browsers.npm i react-linkify-it
Every prebuilt component also optionally accepts a className
to attach to the link wrapper
import { LinkItUrl } from 'react-linkify-it';
const App = () => (
<div className="App">
<LinkItUrl>
<p>"add some link https://www.google.com here"</p>
</LinkItUrl>
</div>
);
import { LinkItJira } from 'react-linkify-it';
const App = () => (
<div className="App">
<LinkItJira domain="https://projectid.atlassian.net">
hello AMM-123 ticket
</LinkItJira>
</div>
);
import { LinkItTwitter } from 'react-linkify-it';
const App = () => (
<div className="App">
<LinkItTwitter>
hello @anantoghosh twitter
</LinkItTwitter>
</div>
);
import { LinkItEmail } from 'react-linkify-it';
const App = () => (
<div className="App">
<LinkItEmail>
hello example@gmail.com email
</LinkItEmail>
</div>
);
import { LinkIt } from 'react-linkify-it';
const regexToMatch = /@([\w_]+)/;
const App = () => (
<div className="App">
<LinkIt
{/* Component to wrap each match with */}
component={(match, key) => <a href={match} key={key}>{match}</a>}
regex={regexToMatch}
>
www.google.com<div>hi @anantoghosh</div>
</LinkIt>
</div>
);
import { linkIt, UrlComponent } from 'react-linkify-it';
const regexToMatch = /@([\w_]+)/;
const App = () => {
const output = linkIt(
// Text to be linkified
text,
// Component to wrap each match with, can be any React component
(match, key) => <UrlComponent match={match} key={key} />,
regexToMatch
);
return <div className="App">{output}</div>
};
Just use more than one component to match multiple patterns.
import { LinkItEmail, LinkItUrl } from 'react-linkify-it';
const App = () => (
<div className="App">
<LinkItUrl>
<LinkItEmail>
hello example@gmail.com https://google.com
</LinkItEmail>
</LinkItUrl>
</div>
);
By default, when you import react-linkify-it
, it will use a modern bundle
meant for browsers which
support RegExp Unicode property escapes.
If you are using babel-preset-env
, or any bundler configuration which uses it (e.g. create-react-app
, vite
) with a
browser which does not support RegExp Unicode property escapes, babel will
transform the code to support the browsers resulting in a larger bundle.
If your setup does not use babel-preset-env
and you would still like to support
older browsers, you can use the legacy bundle by importing:
import { linkIt, LinkIt } from "react-linkify-it/legacy";
import { linkIt, LinkIt } from "react-linkify-it/dist/react-linkify-it.legacy.esm.min";
Note: Legacy bundle has a larger file size (~3.4Kb minziped).
An umd build with legacy browser support can be used from Unpkg.
This project was made possible due to the incredible work done on the following projects:
This project is licensed under the MIT License - see the LICENSE file for details.
Hey 👋 If my packages has helped you in any way, consider making a small donation to encourage me to keep contributing. Maintaining good software takes time and effort and for open source developers there is very less incentives to do so. Your contribution is greatly appreciated and will motivate me to continue to support developing my packages which you may have used.
FAQs
A tiny and dependency free universal linking solution that turns any pattern in your text into clickable links (aka linkify). Supports i18n and emojis.
The npm package react-linkify-it receives a total of 10,919 weekly downloads. As such, react-linkify-it popularity was classified as popular.
We found that react-linkify-it demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.
Research
Security News
Socket researchers uncover the risks of a malicious Python package targeting Discord developers.
Security News
The UK is proposing a bold ban on ransomware payments by public entities to disrupt cybercrime, protect critical services, and lead global cybersecurity efforts.