# babel-plugin-transform-jsx-to-html

> Transform JSX to HTML.

Latest version **0.2.1** (published 2020-06-11) · BSD-3-Clause license · 0 weekly downloads

## Install

```sh
npm install babel-plugin-transform-jsx-to-html
pnpm add babel-plugin-transform-jsx-to-html
yarn add babel-plugin-transform-jsx-to-html
bun add babel-plugin-transform-jsx-to-html
```

## Health

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

Positive: no vulnerabilities.

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

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.2.1 |
| Published | 2020-06-11 |
| First published | 2019-09-17 |
| Weekly downloads | 0 |
| License | BSD-3-Clause |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 2 |
| Unpacked size | 21.7 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 112 |
| Maintainers | chenjun1011, rax-publisher |

## Links

- npm: https://www.npmjs.com/package/babel-plugin-transform-jsx-to-html
- Repository: https://github.com/raxjs/rax-scripts
- Homepage: https://github.com/raxjs/rax-scripts#readme
- Issues: https://github.com/raxjs/rax-scripts/issues
- npm.io page: https://npm.io/package/babel-plugin-transform-jsx-to-html

## Dependencies (2)

- [esutils](https://npm.io/package/esutils.md) ^2.0.3
- [@babel/types](https://npm.io/package/@babel/types.md) ^7.5.5

## Recent versions

- 0.2.1 (latest) — 2020-06-11
- 0.2.1-beta.9 (beta) — 2022-05-11
- 0.2.1-beta.8 — 2022-02-16
- 0.2.1-beta.7 — 2021-12-23
- 0.2.1-beta.6 — 2021-12-22
- 0.2.1-beta.5 — 2021-12-22
- 0.2.1-beta.4 — 2021-12-22
- 0.2.1-beta.3 — 2021-12-22
- 0.2.1-beta.2 — 2021-12-22
- 0.2.1-beta.1 — 2021-12-13
- 0.2.1-beta.0 — 2020-06-09
- 0.2.0 — 2019-12-17
- 0.1.0 — 2019-09-17

## README

# babel-plugin-transform-jsx-to-html
> Transform jsx to html string for better ssr performance.

## Installation

```sh
npm install --save-dev babel-plugin-transform-jsx-to-html
```

## Usage

### Via `.babelrc`

**.babelrc**

```json
{
  "plugins": [
    "babel-plugin-transform-jsx-to-html",
    "babel/plugin-transform-react-jsx"
  ]
}
```

## Example

### basic example

Your `component.js` that contains this code:

```js
import { createElement, Component } from 'rax';

class App extends Component {
  render() {
    return <div className="header" />
  }
}
```

Will be transpiled like this:

```js
import { createElement, Component } from 'rax';

class App extends Component {
  render() {
    return [{
      __html: '<div class="header" />'
    }];
  }
}
```

These pre transpiled html can be used in server renderer, like [rax-server-renderer](https://github.com/raxjs/rax-scripts/tree/master/packages/rax-server-renderer)

### more examples

input 

```jsx
<div>
  <View />
</div>
```

output

```js
[{
   __html: "<div>"
}, 
createElement(View, null),
{
  __html: "</div>"
}]
```

input 

```jsx
<div className="container" style={style} onClick={onClick}>
  <div>a {props.index}</div>
</div>
```

output

```js
[{
  __html: "<div class=\"container\""
}, {
  __attrs: {
    style: style,
    onClick: onClick
  }
}, {
  __html: "><div>a "
}, props.index, {
  __html: "</div></div>"
}]
```

---
_Source: https://npm.io/package/babel-plugin-transform-jsx-to-html · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
