AsterDocsv1.2.3

Docs / Start here

Choosing Aster

A developer opens a preview deployment and clicks Revoke key. The next step depends on their answer. In Aster, the caller can use revoked = yield* confirmRevoke() and pick up on that same line when the confirmation returns. Try keeping the key once, then revoking it. Run the confirmation example.

Why not just use CrankJS?

Crank is a natural choice if you want a JavaScript generator to own local state. Both counters below keep a variable alive across clicks. Press each number, then open Code + CSS to see the file that runs it. The benchmark uses these same component files. The preview CSS styles the buttons and is excluded from the JavaScript measurements.

Aster

Crank

Look at the click handlers. Crank’s handler calls this.refresh(() => count++). Crank advances the generator, receives a new element, and updates the DOM. In Aster, the handler increments n. Aster schedules an update after the event, and its compiler has already identified the button’s dynamic text slot. Both approaches preserve local variables. You can inspect the output of the Aster compiler to see where the text goes. Crank components.

Choose Crank if its explicit refresh model suits your team or you want components to render beyond the DOM. Crank supports async components and lets you supply a renderer for a target such as canvas. An existing Crank editor gets little from a rewrite solely to keep using generators. Async components · Custom renderers.

Try Aster if your page sends HTML first and has controls that many visitors never touch. Crank gives the application a renderer.hydrate() call for attaching to server markup. Aster marks interactive islands in the HTML. Its loader can preload a component on pointer entry or focus. The first qualifying click activates the component and replays the event on the existing control. The ticket example shows the browser’s module request alongside the seat count. In an Astro page, Astro’s client directive chooses the timing. Crank hydration · Aster first-click revival · Aster inside Astro.

Inspect Crank’s refresh, renderer and hydration signatures
Crank 0.7.14 · excerpts from crank.d.ts and dom.d.ts
refresh(callback?: () => unknown): Promise<TResult> | TResult;

constructor(adapter: Partial<RenderAdapter<TNode, TScope, TRoot, TResult>>);

hydrate(children: Children, root: Element, ctx?: Context): Promise<ElementValue<Node>> | ElementValue<Node>;

Five ways to update one button

Framework How a local change reaches the DOM What to weigh
Aster The click handler updates a local variable. The component advances to its next yield and the runtime updates slots in a compiled template. A short workflow can read like ordinary procedural code. Teams must learn when a generator advances, delegates and cleans up.
Crank An explicit refresh advances the generator. Its renderer applies the yielded element tree to the target. Useful when the same component model needs to support a custom renderer.
React A setter schedules a render. React computes the next UI and commits the necessary DOM changes. A good fit for existing React component libraries and teams fluent in hooks. Rendering a component does not imply rewriting its entire DOM.
Vue Reactive reads track dependencies. Compiled templates can mark dynamic parts so the renderer can skip static work. Single-file components combine templates, script and styling. Using render functions changes what the compiler can optimize.
Svelte Its compiler translates a component and reactive declarations into targeted runtime work. A good fit when the team likes a dedicated component language and compiler-assisted reactivity. Bundle cost depends on which features the app uses.

For the rendering details, see React render and commit, Vue rendering mechanism, Svelte overview.

Browser size and update speed

We built the same client-mounted counter five ways. Each page starts at zero and increments a button’s text by one on click. These are whole example JavaScript payloads requested during the run, including the runtime. Values use KiB (1,024 bytes) and gzip level 9 per file.

Counter build Loaded JS, gzip Median time for 100 updates Range across 7 batches
Aster 1.2.3 6.56 KiB 1.1 ms 0.7–1.6 ms
Crank 0.7.14 12.27 KiB 1.5 ms 1.1–2.3 ms
React + React DOM 19.3.1 65.73 KiB 3.1 ms 2.0–5.3 ms
Vue 3.5.46 20.57 KiB 1.6 ms 0.7–2.2 ms
Svelte 5.59.2 13.13 KiB 2.1 ms 1.1–3.0 ms

The Crank counter loaded 5.71 KiB more compressed JavaScript than the Aster counter. Their median batch times differed by 0.4 ms across 100 updates on this machine. The timing ranges overlap. These numbers can help estimate a small widget’s download cost. They say little about perceived latency on a real page.

Inspect the implementations

React
react.js
import { createElement, useState } from "react";
import { createRoot } from "react-dom/client";
function Counter() {
  const [n, set] = useState(0);
  return createElement("button", { onClick: () => set((v) => v + 1) }, n);
}
createRoot(document.body).render(createElement(Counter));
Vue
vue.js
import { createApp, ref, h } from "vue";
createApp({
  setup() {
    const n = ref(0);
    return () => h("button", { onClick: () => n.value++ }, n.value);
  },
}).mount(document.body);
Svelte
Counter.svelte
<script>let n=$state(0);</script><button onclick={()=>n++}>{n}</button>
svelte.js
import { mount } from "svelte";
import Counter from "./Counter.svelte";
mount(Counter, { target: document.body });
Build and measurement scripts
build-counter.mjs
import { build } from "vite-plus";
import aster from "@fierst/aster/vite";
import { fileURLToPath } from "node:url";

export async function buildCounter(entry, pkg, root, plugins = []) {
  const built = await build({
    root,
    configFile: false,
    publicDir: false,
    logLevel: "silent",
    plugins: [pkg === "@fierst/aster" ? aster() : null, ...plugins],
    define: {
      "process.env.NODE_ENV": '"production"',
      __VUE_OPTIONS_API__: "false",
      __VUE_PROD_DEVTOOLS__: "false",
      __VUE_PROD_HYDRATION_MISMATCH_DETAILS__: "false",
    },
    build: {
      write: false,
      modulePreload: false,
      rolldownOptions: { input: fileURLToPath(new URL(entry, import.meta.url)) },
    },
    resolve: { dedupe: [pkg], conditions: ["browser", "production", "module", "import"] },
  });
  const chunks = built.output.filter((x) => x.type === "chunk");
  const start = chunks.find((x) => x.facadeModuleId?.replaceAll("\\", "/").endsWith("/" + entry));
  if (!start) throw Error(JSON.stringify(chunks.map((x) => [x.fileName, x.facadeModuleId])));
  return { chunks, start };
}
measure.mjs
import { buildCounter } from "./build-counter.mjs";
import { compile } from "svelte/compiler";
import { chromium } from "playwright";
import { readFileSync } from "node:fs";
import { gzipSync } from "node:zlib";
import os from "node:os";
const browser = await chromium.launch(
  process.env.BROWSER_EXECUTABLE ? { executablePath: process.env.BROWSER_EXECUTABLE } : {},
);
try {
  console.log(
    process.version,
    os.platform(),
    os.arch(),
    os.cpus()[0].model,
    await browser.version(),
  );
  const fixtures = [
    ["aster.jsx", "@fierst/aster"],
    ["crank.jsx", "@b9g/crank"],
    ["react.js", "react"],
    ["vue.js", "vue"],
    ["svelte.js", "svelte"],
  ];
  for (const [entry, pkg] of fixtures) {
    const plugins =
      pkg === "svelte"
        ? [
            {
              name: "compile-svelte",
              transform(src, id) {
                if (id.endsWith(".svelte"))
                  return compile(src, { filename: id, generate: "client", dev: false }).js.code;
              },
            },
          ]
        : [];
    const { chunks, start } = await buildCounter(entry, pkg, process.cwd(), plugins);
    const page = await browser.newPage();
    page.on("pageerror", (e) => console.error(e));
    const loaded = new Map();
    await page.route("http://measure.test/**", (route) => {
      const file = new URL(route.request().url()).pathname.slice(1);
      if (!file)
        return route.fulfill({
          contentType: "text/html",
          body:
            '<!doctype html><body><script type="module" src="/' +
            start.fileName +
            '"></script></body>',
        });
      const chunk = chunks.find((x) => x.fileName === file);
      if (!chunk) return route.fulfill({ status: 404 });
      loaded.set(file, chunk.code);
      return route.fulfill({ contentType: "text/javascript", body: chunk.code });
    });
    await page.goto("http://measure.test");
    await page.waitForSelector("button");
    const times = await page.evaluate(async () => {
      const b = document.querySelector("button"),
        samples = [];
      let count = 0;
      for (let run = 0; run < 8; run++) {
        const t = performance.now();
        for (let i = 0; i < 100; i++) {
          const changed = new Promise((resolve) => {
            const observer = new MutationObserver(() => {
              observer.disconnect();
              resolve();
            });
            observer.observe(b, { subtree: true, childList: true, characterData: true });
          });
          b.click();
          await changed;
          if (+b.textContent !== ++count) throw Error("Missed update");
        }
        if (run) samples.push(performance.now() - t);
      }
      return samples;
    });
    const bytes = [...loaded.values()].reduce((n, s) => n + gzipSync(s, { level: 9 }).length, 0);
    console.log(
      pkg,
      JSON.parse(readFileSync("node_modules/" + pkg + "/package.json")).version,
      bytes,
      times.sort((a, b) => a - b),
    );
    await page.close();
  }
} finally {
  await browser.close();
}

How to reproduce it

Download the benchmark fixture and lockfile, extract it, and run these commands from the directory containing its package.json.

sh
npm ci
npx playwright install chromium
npm run measure

We used Node 24.22.1, Vite+ 1.8.0 production builds, headless Chromium 159.0.8154.6 on Windows x64 and a Ryzen 9 5950X. Aster uses its JSX compiler. Crank uses its standard JSX runtime, generator context and DOM renderer. React uses createRoot and useState, Vue uses the runtime with a setup/render function, and Svelte uses its client compiler and $state. Each build runs in a fresh page. After 100 warm-up clicks, each of seven batches dispatches 100 programmatic clicks, waiting for a MutationObserver to see the correct increment before the next click. The timer includes event dispatch and observation. It stops after the last DOM mutation, before the browser needs to paint the result. An optional BROWSER_EXECUTABLE environment variable selects an installed Chromium.

What a project benchmark should add

This fixture omits CSS, HTML bytes, network delays, hydration, frame painting and user input latency. It measures one version and one workload. A searchable table with thousands of rows exercises allocation, keyed updates and scrolling. A product page on a slow connection exercises transfer, parsing and first interaction. Measure the critical task on a target device with the integrations you expect to ship before choosing a framework on speed alone.

Where Astro fits

Astro can render an entire content page to HTML and ship zero component JavaScript when it has no client islands. An Aster, React, Vue or Svelte island adds its own client payload and activation work. Comparing that static Astro page against an interactive counter would answer a different question. Use Astro for the page and choose a renderer for each interactive island. Astro’s islands architecture.

For an existing Astro site, add an Aster widget on one route and measure what changes. For an app dominated by multi-step interactions, start with a representative Aster workflow and check how cancellation, focus and retry feel in practice. Aster in Astro · Confirmation flow example.