# @bobderrico/react-html-parser

> A lightweight parser to convert an HTML string into React elements

Latest version **1.0.0** (published 2021-03-01) · MIT license · 0 weekly downloads

## Install

```sh
npm install @bobderrico/react-html-parser
pnpm add @bobderrico/react-html-parser
yarn add @bobderrico/react-html-parser
bun add @bobderrico/react-html-parser
```

## Health

**Score 20/100 (F)** — status: abandoned.

Positive: esm support; no vulnerabilities.

Warnings: low downloads; no types.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.0 |
| Published | 2021-03-01 |
| First published | 2021-03-01 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | ESM + CommonJS |
| Node | >=10 |
| Dependencies | 0 |
| Unpacked size | 51.2 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | bobderrico80 |
| Maintainers | bobderrico |

## Links

- npm: https://www.npmjs.com/package/@bobderrico/react-html-parser
- Repository: https://github.com/bobderrico80/react-html-parser
- Homepage: https://github.com/bobderrico80/react-html-parser#readme
- Issues: https://github.com/bobderrico80/react-html-parser/issues
- npm.io page: https://npm.io/package/@bobderrico/react-html-parser

## Recent versions

- 1.0.0 (latest) — 2021-03-01

## README

# @bobderrico/react-html-parser

> A lightweight parser to convert an HTML string into React elements

[![NPM](https://img.shields.io/npm/v/@bobderrico/react-html-parser.svg)](https://www.npmjs.com/package/@bobderrico/react-html-parser) [![JavaScript Style Guide](https://img.shields.io/badge/code_style-standard-brightgreen.svg)](https://standardjs.com)

## Install

```bash
npm install --save @bobderrico/react-html-parser
```

## Usage

```tsx
import React from 'react'
import { parseHTML } from '@bobderrico/react-html-parser'

const html = '<h1><strong>Hello</strong> world!</h1>'

const Component = () => {
  return <div>{parseHTML(html)}</div>
}
```

The above `<Component />` would render as so:

```html
<div>
  <h1><strong>Hello</strong> world!</h1>
</div>
```

For more examples, see https://bobderrico80.github.io/react-html-parser/

## Inspiration

There are several other solutions out there that solve a similar problem, [`html-react-parser`](https://www.npmjs.com/package/html-react-parser), [`react-html-parser`](https://www.npmjs.com/package/react-html-parser), and [`html-to-react`](https://www.npmjs.com/package/html-to-react) to name a few. I wanted to challenge myself to build one of my own with a more familiar API, especially in regards to the `replacer` function, as that function is called with an `HTMLElement`.

This package relies on `DOMParser` and therefore currently only works in the browser.

## License

MIT © [bobderrico80](https://github.com/bobderrico80)

---
_Source: https://npm.io/package/@bobderrico/react-html-parser · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
