# @mapbox/hast-util-to-jsx

> Transform HAST to JSX

Latest version **2.1.0** (published 2023-11-13) · MIT license · 0 weekly downloads

## Install

```sh
npm install @mapbox/hast-util-to-jsx
pnpm add @mapbox/hast-util-to-jsx
yarn add @mapbox/hast-util-to-jsx
bun add @mapbox/hast-util-to-jsx
```

## Health

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

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 2.1.0 |
| Published | 2023-11-13 |
| First published | 2018-04-10 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >=18 |
| Dependencies | 7 |
| Unpacked size | 28.6 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 92 |
| Author | Mapbox |
| Maintainers | mbx-npm-ci-production, mbx-npm-ci-staging, mbx-npm-advanced-actions-production, mbx-npm-advanced-actions-staging, mbx-npm-09-production, mbx-npm-08-production, mbx-npm-07-production, mbx-npm-06-production, mbx-npm-05-production, mbx-npm-04-production, mbx-npm-03-production, mbx-npm-02-production, mbx-npm-01-production, mbx-npm-02-staging, mapbox-npm-01, mapbox-npm-02, mapbox-npm-07, mapbox-npm-03, mapbox-npm-04, mapbox-npm-09, mapbox-npm-05, mapbox-npm-06, mapbox-npm-08, mapbox-npm-advanced-actions, mapbox-npm-ci, mapbox-npm, mapbox-admin, mapbox-machine-user |
| Keywords | hast, plugin, markdown, html, react, jsx, transform |

## Links

- npm: https://www.npmjs.com/package/@mapbox/hast-util-to-jsx
- Repository: https://github.com/mapbox/jsxtreme-markdown
- Homepage: https://github.com/mapbox/jsxtreme-markdown/tree/main/packages/hast-util-to-jsx#readme
- Issues: https://github.com/mapbox/jsxtreme-markdown/issues
- npm.io page: https://npm.io/package/@mapbox/hast-util-to-jsx

## Dependencies (7)

- [postcss](https://npm.io/package/postcss.md) ^8.4.31
- [kebab-case](https://npm.io/package/kebab-case.md) ^1.0.0
- [postcss-js](https://npm.io/package/postcss-js.md) ^4.0.1
- [stringify-object](https://npm.io/package/stringify-object.md) ^3.3.0
- [stringify-entities](https://npm.io/package/stringify-entities.md) ^3.0.1
- [property-information](https://npm.io/package/property-information.md) ^5.5.0
- [react-attr-converter](https://npm.io/package/react-attr-converter.md) ^0.3.1

## Alternatives

- [mobx-react](https://npm.io/package/mobx-react.md) — 2.8M weekly downloads
- [rc-tree](https://npm.io/package/rc-tree.md) — 2.6M weekly downloads
- [@react-oauth/google](https://npm.io/package/@react-oauth/google.md) — 1.3M weekly downloads
- [@wagmi/connectors](https://npm.io/package/@wagmi/connectors.md) — 877.0K weekly downloads
- [vee-validate](https://npm.io/package/vee-validate.md) — 836.4K weekly downloads

## Recent versions

- 2.1.0 (latest) — 2023-11-13
- 2.0.0 — 2021-11-24
- 1.1.0 — 2021-11-18
- 1.0.0 — 2020-06-04
- 0.1.0 — 2018-04-10

## README

# @mapbox/hast-util-to-jsx

Transform [HAST](https://github.com/syntax-tree/hast) to JSX.

## Installation

```
npm install @mapbox/hast-util-to-jsx
```

## Usage

```js
const h = require('hyperscript');
const toJsx = require('@mapbox/hast-util-to-jsx');

const tree = h('div.one.two', id: 'bar' }, [
  h('p.hidden', { ariaHidden: true }, ['hidden text']),
  h('p', { style: 'color: pink; font-size: 2em;' }, ['fancy text'])
]);

console.log(toJsx(tree));
```

Yields (with whitespace collapsed):

```jsx
<div className="one two" id="bar">
  <p className="hidden" aria-hidden={true}>hidden text</p>
  <p style={{color: "pink", fontSize: "2em"}}>fancy text</p>
</div>
```

A few libraries exist to transform HTML to JSX.
Using this util, you can perform that transformation entirely within the ecosystem of [`unified`](https://github.com/unifiedjs/unified) syntax trees, using [`rehype`](https://github.com/rehypejs/rehype) to parse HTML and this util to stringify the tree into JSX.

## Related

- [`hast-util-to-html`](https://github.com/syntax-tree/hast-util-to-html) — Transform HAST to HTML.
- [`rehype`](https://github.com/rehypejs/rehype) — Process HTML as HAST.

---
_Source: https://npm.io/package/@mapbox/hast-util-to-jsx · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
