Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

linkify-react

Package Overview
Dependencies
Maintainers
1
Versions
19
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

linkify-react

React element interface for linkifyjs

  • 4.2.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
253K
increased by6.38%
Maintainers
1
Weekly downloads
 
Created

What is linkify-react?

The linkify-react npm package is a React component for converting plain text containing URLs, email addresses, and hashtags into clickable links. It is useful for dynamically rendering user-generated content where such elements need to be identified and converted into interactive links.

What are linkify-react's main functionalities?

Convert URLs to clickable links

This feature allows you to convert plain text URLs into clickable links. The `defaultProtocol` option ensures that URLs without a specified protocol are treated as HTTPS links.

import React from 'react';
import Linkify from 'linkify-react';

const options = {
  defaultProtocol: 'https'
};

const text = 'Check out this website: www.example.com';

const App = () => (
  <Linkify options={options}>{text}</Linkify>
);

export default App;

Convert email addresses to mailto links

This feature converts plain text email addresses into clickable mailto links, making it easy for users to send emails directly from the rendered content.

import React from 'react';
import Linkify from 'linkify-react';

const text = 'Contact us at support@example.com';

const App = () => (
  <Linkify>{text}</Linkify>
);

export default App;

Convert hashtags to clickable links

This feature converts hashtags into clickable links. The `formatHref` option allows you to customize the URL format for hashtags, such as linking to a Twitter search for the hashtag.

import React from 'react';
import Linkify from 'linkify-react';

const options = {
  formatHref: (href, type) => {
    if (type === 'hashtag') {
      return 'https://twitter.com/hashtag/' + href.substring(1);
    }
    return href;
  }
};

const text = 'Follow the conversation at #example';

const App = () => (
  <Linkify options={options}>{text}</Linkify>
);

export default App;

Other packages similar to linkify-react

Keywords

FAQs

Package last updated on 04 Dec 2024

Did you know?

Socket

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc