Alchemist [html-alchemist]

Dangerously simple JS microframework. Around the web in 80 lines.

Turn concise Reagent-style HTML expressions into vibrant applications. Friends with WebComponents. See the README for more information.

Consider the source for a simple counter:

import { alchemize, snag } from "./alchemist.js"

function counterview () {
  // no reactive state. you control when and what to re-render.
  let i = 0
  function onclick () {
    // interact directly with the DOM. dispel the magic.
    snag('counter').innerText = String(++i)
  }
  // stop writing end tags. set attributes tersely.
  return alchemize(['button#counter', { onclick, style: 'width: 100%;' }, i])
}

// forget react. make your own elements with webcomponents.
class CounterApp extends HTMLElement {
  connectedCallback () {
    this.appendChild(counterview())
  }
}

customElements.define('counter-app', CounterApp)

Examples

A simple counter:

Source: counter.js

A todo list:

Source: todo.js

A searchable blog:

Source: logbook.js

Playground / scratchpad:

Source: playground.js