
Security News
New CVE Forecasting Tool Predicts 47,000 Disclosures in 2025
CVEForecast.org uses machine learning to project a record-breaking surge in vulnerability disclosures in 2025.
react-html-string
Advanced tools
A React declarative component for converting HTML strings into React components. Avoids the use of dangerouslySetInnerHTML and converts standard HTML elements, attributes and inline styles into their React equivalents or `Custom Components`.
A React declarative component for converting HTML strings into React components. Avoids the use of dangerouslySetInnerHTML and converts standard HTML elements, attributes and inline styles into their React equivalents or Custom Components
.
$ npm install react-html-string
or
$ yarn add react-html-string
import HTMLString from 'react-html-string';
const html = `
<div>
<h1>
Hello from
<a
href="https://github.com/MomenSherif/react-html-string"
target="_blank"
>React HTML String</a
>
</h1>
<hr />
<ul>
<li>Render HTML string safely</li>
<li>Provide <b>Custom Components</b> if needed</li>
</ul>
<p>Don't forget to ⭐️ the project</p>
</div>
`;
export default function App() {
return (
<div>
<h1>Hello, React!</h1>
<HTMLString html={html} />
</div>
);
}
import HTMLString from 'react-html-string';
import Heading from './components/Heading';
const components = {
a: props => <a {...props} style={{ color: 'red' }} />,
h1: Heading,
};
const html = `
<div>
<h1>
Hello from
<a
href="https://github.com/MomenSherif/react-html-string"
target="_blank"
>React HTML String</a
>
</h1>
<hr />
<ul>
<li>Render HTML string safely</li>
<li>Provide <b>Custom Components</b> if needed</li>
</ul>
<p>Don't forget to ⭐️ the project</p>
</div>
`;
export default function App() {
return (
<div>
<h1>Hello, React!</h1>
<HTMLString html={html} components={components} />
</div>
);
}
Each component is strongly typed with the equivalent dom node type.
import HTMLString, { Components } from 'react-html-string';
import Heading from './components/Heading';
const components: Components = {
a: props => <a {...props} style={{ color: 'red' }} />,
h1: Heading,
};
const html = `
<div>
<h1>
Hello from
<a
href="https://github.com/MomenSherif/react-html-string"
target="_blank"
>React HTML String</a
>
</h1>
<hr />
<ul>
<li>Render HTML string safely</li>
<li>Provide <b>Custom Components</b> if needed</li>
</ul>
<p>Don't forget to ⭐️ the project</p>
</div>
`;
export default function App() {
return (
<div>
<h1>Hello, React!</h1>
<HTMLString html={html} components={components} />
</div>
);
}
FAQs
A React declarative component for converting HTML strings into React components. Avoids the use of dangerouslySetInnerHTML and converts standard HTML elements, attributes and inline styles into their React equivalents or `Custom Components`.
The npm package react-html-string receives a total of 485 weekly downloads. As such, react-html-string popularity was classified as not popular.
We found that react-html-string 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
CVEForecast.org uses machine learning to project a record-breaking surge in vulnerability disclosures in 2025.
Security News
Browserslist-rs now uses static data to reduce binary size by over 1MB, improving memory use and performance for Rust-based frontend tools.
Research
Security News
Eight new malicious Firefox extensions impersonate games, steal OAuth tokens, hijack sessions, and exploit browser permissions to spy on users.