# @ncpa0cpl/vanilla-jsx

> *VanillaJSX provides a syntactic sugar for creating HTMLElements.*

Latest version **0.0.1-alpha.56** (published 2026-10-28) · MIT license · 0 weekly downloads

## Install

```sh
npm install @ncpa0cpl/vanilla-jsx
pnpm add @ncpa0cpl/vanilla-jsx
yarn add @ncpa0cpl/vanilla-jsx
bun add @ncpa0cpl/vanilla-jsx
```

## Health

**Score 70/100 (B)** — status: active.

Positive: has types; esm support; no vulnerabilities; has provenance; recently updated; high maintenance score.

Warnings: low downloads; pre 1.0.

## Facts

| | |
|---|---|
| Version | 0.0.1-alpha.56 |
| Published | 2026-10-28 |
| First published | 2024-01-04 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 2 |
| Unpacked size | 629.4 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Provenance | attested (GitHub Actions) |
| GitHub stars | 1 |
| Author | Szymon Bretner |
| Maintainers | ncpa0cpl |
| Keywords | jsx, createElement |

## Links

- npm: https://www.npmjs.com/package/@ncpa0cpl/vanilla-jsx
- Repository: https://github.com/ncpa0/vanilla-jsx
- Homepage: https://github.com/ncpa0/vanilla-jsx#readme
- Issues: https://github.com/ncpa0/vanilla-jsx/issues
- npm.io page: https://npm.io/package/@ncpa0cpl/vanilla-jsx

## Dependencies (2)

- [immer](https://npm.io/package/immer.md) ^10.1.1
- [html-element-attributes](https://npm.io/package/html-element-attributes.md) ^3.4.0

## Recent versions

- 0.0.1-alpha.56 (latest) — 2026-10-28
- 0.0.1-alpha.55 — 2026-10-28
- 0.0.1-alpha.54 — 2026-10-07
- 0.0.1-alpha.53 — 2026-10-02
- 0.0.1-alpha.52 — 2026-09-29
- 0.0.1-alpha.51 — 2026-09-28
- 0.0.1-alpha.50 — 2026-08-11
- 0.0.1-alpha.49 — 2026-07-08
- 0.0.1-alpha.48 — 2026-07-08
- 0.0.1-alpha.47 — 2026-07-08
- 0.0.1-alpha.46 — 2026-07-06
- 0.0.1-alpha.45 — 2026-02-01
- 0.0.1-alpha.44 — 2025-09-28
- 0.0.1-alpha.43 — 2025-05-17
- 0.0.1-alpha.42 — 2025-05-16
- … 40 more at https://npm.io/package/@ncpa0cpl/vanilla-jsx/versions

## README

# VanillaJSX

*VanillaJSX provides a syntactic sugar for creating HTMLElements.*

It is a JSX render library that compiles JSX **directly to real DOM elements** — no virtual DOM, no diffing, no re-render loop. JSX runs once, eagerly building real `HTMLElement`s, and all dynamic behavior is driven by [signals](./docs/signals.md) bound to element attributes, children and event listeners at creation time.

These two snippets are equivalent:

```typescript
const container = document.createElement('div');
const header = document.createElement('h1');
header.textContent = 'Hello, world!';
header.classList.add('custom-header');
container.setAttribute('id', 'header-container');
container.appendChild(header);
```

```tsx
const container = (
    <div id="header-container">
        <h1 class="custom-header">Hello, world!</h1>
    </div>
);
```

## Installation

```bash
yarn add @ncpa0cpl/vanilla-jsx
```

Enable the JSX transform in your `tsconfig.json`:

```json
{
    "compilerOptions": {
        "jsx": "react-jsx",
        "jsxImportSource": "@ncpa0cpl/vanilla-jsx"
    }
}
```

Set the same option in your bundler, e.g. for `esbuild`:

```javascript
esbuild
  .build({
    jsxImportSource: "@ncpa0cpl/vanilla-jsx",
    ...rest
  })
```

## Quick example

```tsx
import { sig } from "@ncpa0cpl/vanilla-jsx/signals";

function getCounterComponent() {
    const counter = sig(0);

    return (
        <div>
            <button
                class={counter.derive(c => `counter_${c}`)}
                onClick={() => counter.dispatch(current => current + 1)}
            >
                Click me!
            </button>
            <p>{counter}</p>
        </div>
    );
}
```

The built-in signal library is optional — interops are provided for [JS Signals, mini-signals and @preact/signals-core](./docs/interop.md#provided-interop), and any other implementation can be plugged in via `SignalsReg`.

## Documentation

| Document | Contents |
| --- | --- |
| [Signals](./docs/signals.md) | The built-in signal library: `sig`, derive, combinators, batching, GC-based cleanup. |
| [Signal Freezing](./docs/singal-freezing.md) | Stopping signal driven DOM mutation in selected sub-trees. |
| [Working with JSX](./docs/jsx.md) | Setup, elements, fragments, props, events, reactive attributes, `class`/`style`, `boundSignal`, `unsafeHTML`, components. |
| [Components](./docs/components.md) | `<If>`, `<Switch>`/`<Case>`, `<Range>`, `<VirtualList>`, `$component` lifecycle, `ClassComponent`. |
| [Interop](./docs/interop.md) | Registering other signal implementations, swapping the DOM layer. |
| [Gotchas and limitations](./docs/gotchas.md) | Rendering model, GC cleanup rules, XSS notes, batching semantics, environment requirements. |

## License

MIT

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