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

html-converter-react

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

html-converter-react

**html-converter-react** is an isomorphic utility function that provides easy way to convert your string into a safely sanitized html. It's built on top of dompurify and it's made to work with react.

  • 2.0.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

html-converter-react

html-converter-react is an isomorphic utility function that provides easy way to convert your string into a safely sanitized html. It's built on top of dompurify and it's made to work with react.

Works both on server side and client side (CSR/SSR). You can use Next.js/Gatsby.js/CRA

Full documentation on: https://github.com/Blagoj5/html-converter#readme

Installation
npm install html-converter-react
yarn add html-converter-react
Usage
import { htmlConverterReact } from 'html-converter-react';

const text = '<p>Paragraph</p>';
const textEls = '<p>Paragraph</p><p>Second paragraph</p>';
const dangerousText = '<p>Paragraph<script></script></p>';

const App = () => {
  return (
    <div>
      <h1>My App</h1>
      {htmlConverterReact(text)}
      {htmlConverterReact(textEls)}
      {htmlConverterReact(dangerousText)}
    </div>
  );
};

Explanation:

  • htmlConverterReact(text) - returns JSX.Element paragraph
  • htmlConverterReact(textEls) - returns JSX.Element paragraph with sanitized data: <p>Paragraph</p> (without script tag)
  • htmlConverterReact(dangerousText) - returns JSX.Element[] array of jsx elements, two paragraphs
Options
OptionDescriptionDefault
strThe string to be sanitized and parsed into a html
dompurifyConfigDompurify optionsundefined
htmlParserConfigHTMLReactParserOptions{trim: true}

Keywords

FAQs

Package last updated on 02 Feb 2023

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