picojsx

0.1.0 • Public • Published

picojsx

Tiny (under 1k), zero-dependency JSX renderer - built for Cloudflare Workers, but works everywhere!

Installation

npm install picojsx

Examples

Render JSX to HTML

// @jsxRuntime automatic
// @jsxImportSource picojsx
import { renderToString } from "picojsx";

let vnode = <div class="foo">content</div>;
let html = renderToString(vnode);
console.log(html);
// <div class="foo">content</div>

Render JSX inside Workers

// @jsxRuntime automatic
// @jsxImportSource picojsx
import { render } from "picojsx";

export default {
  fetch: (request) => render(<h1>Hello {request.url}!</h1>),
};

Run it with wrangler:

wrangler dev --local index.jsx

API

renderToString(vnode): string

Renders the given vnode to HTML.

render(vnode, options = {}): Response

Renders the given vnode to HTML and wraps it in a Response.

Versions

Current Tags

  • Version
    Downloads (Last 7 Days)
    • Tag
  • 0.1.0
    0
    • latest

Version History

  • Version
    Downloads (Last 7 Days)
    • Published
  • 0.1.0
    0

Package Sidebar

Install

npm i picojsx

Weekly Downloads

0

Version

0.1.0

License

MIT

Unpacked Size

2.97 kB

Total Files

4

Last publish

Collaborators

  • xortoast