qat

Qat

A frontend framework in which a component function runs once. What changes afterwards goes straight to the DOM nodes that depend on it: there is no render pass to repeat and nothing to memoize. You write JSX; state, derived values, data loading, routing, forms and stores are words of the language and packages of the framework, typed together.

.qx12 lines, 2 reactive namesOpen in the playground
// counter.qx
export default function Counter({ start = 0 }) {
  let count = state(start)
  let double = derived(count * 2)
  mount(() => console.log('in the document'))

  return (
    <button on:click={() => count++}>
      {count} × 2 = {double}
    </button>
  )
}
count statedouble derived

Counter runs once. Clicking updates one text node.

Getting started

shell3 lines
npm create qatjs my-app     # a new app: package.json, index.html, routes, two pages
cd my-app && npm install
npx qatjs dev               # the dev server; qatjs compress builds, qatjs check checks

The packages are on npm as @qatjs/*, a release candidate of 0.9. Inside this repository, node packages/toolchain/bin/qatjs.js init examples/my-app does the same, and examples/ resolves the workspace's packages without an install. The rest is in dev.md.

The words

Word What it is
state(init) a value that changes: read it as a variable, assign to it
derived(expr) a value computed from others, kept up to date
load(fn) data from a promise: loading, data, error, reload()
effect(fn) runs after mount and when what it reads changes
watch(src, fn) runs when src changes, with the value before
mount(fn) / unmount(fn) when the component's DOM is in the document, and when it leaves
{if} {for} {switch} {try} blocks in the markup: conditions, keyed lists, error boundaries
class, for, on:click, bind:value attributes as HTML names them; events and two-way bindings
provide / inject a value for the components below

Reserved in .qx files (compiler globals — they cannot be imported, declared or shadowed): state derived load effect watch mount unmount idle visible resize lazy emits emit expose provide inject raw shallow ref untrack batch defer transition invariant static. (lazy is reserved, not an API: a component that renders only in a closed {if} is loaded on first render, automatically — compress.)

The one rule to remember

Inside a closure, a state variable is read live. Passed to a function, it passes its current value; to pass the signal itself, write ref(x). An imported signal or store, or one a call gave (const q = query('q', '')), reads the same way in the JSX and in a function beside it. Details: reactivity.md.

What is in it

Piece Where
The runtime: signals, templates, blocks, keyed lists, events, custom elements @qatjs/core
The .qx language and its checks @qatjs/compiler, qatjs check
Router, data, stores, forms, the document head @qatjs/router, @qatjs/load, @qatjs/store, @qatjs/form, @qatjs/head
The toolchain, with no configuration file qatjs init, dev, compress, preview, test
Rendering on a server: server, static, island and edge builds, resumed in the browser @qatjs/server, @qatjs/resume
Federation, and bridges for components written for React, Vue or Angular @qatjs/federate, @qatjs/bridge-*
Moving an existing React app qatjs migrate
Components, copied into your app @qatjs/ui, qatjs add
Devtools: snapshot, replay, repro @qatjs/devtools
Collaboration, secrets, device-encrypted stores @qatjs/core/sync, /secret, @qatjs/vault

CHANGELOG.md has each release.

The language: packages/compiler/SPEC.md. The runtime is also usable directly from JavaScript: runtime.md.

Stability

What 1.0 promises, and what it does not yet (D327). Stable means the API changes only with a major version and an entry in the upgrade ledger. Experimental means it works and is tested, and may change in a minor version: use it, and expect to adapt.

Pieces
Stable @qatjs/core (the entry points the compiler imports, /collections, /i18n), the .qx language and @qatjs/compiler, @qatjs/router, @qatjs/load, @qatjs/store, @qatjs/form, @qatjs/head, the qatjs command's init, dev, check, compress, preview, test, create-qatjs
Experimental render modes (@qatjs/server, @qatjs/resume: server, static, island, edge), federation and the bridges (@qatjs/federate, @qatjs/bridge-*), collaboration (@qatjs/core/sync, /live, /scenario, @qatjs/sync-server, @qatjs/sync-yjs), secrets and @qatjs/vault (until its external audit), @qatjs/ui, the devtools, qatjs migrate, @qatjs/policy, @qatjs/vitals, @qatjs/tanstack-query, the report adapters, the editor, lint and format plugins

Packages and entry points

  • @qatjs/core is the runtime. The compiler imports these of its entry points from the syntax you use, so in .qx and .tsx you never import them (plain .ts/.js files do): @qatjs/core/deep, /deep/collections, /boundary, /transition, /element, /props, /portal, /dynamic, /style, /keep, /schedule, /events (the event layer), /collections/delta, /cold, /live (a load with live: true), /invariant.
  • These you import yourself: @qatjs/core/collections (sum, count, avg, sortBy, groupBy: large collections), /i18n (messages), /version and /version/live, /sync and /live/ws (collaboration), /secret (secrets), /scenario (scenarios).
  • @qatjs/* are separate packages:
    • in the browser: @qatjs/router, @qatjs/store, @qatjs/load, @qatjs/form, @qatjs/head, @qatjs/federate, @qatjs/resume, @qatjs/policy, @qatjs/vault, @qatjs/vitals, @qatjs/sync-yjs, @qatjs/tanstack-query, @qatjs/report-sentry, @qatjs/report-otel, @qatjs/stack;
    • bridges: @qatjs/bridge-react, @qatjs/bridge-vue, @qatjs/bridge-angular;
    • @qatjs/ui, copy-in components such as <VirtualList> (qatjs add);
    • on the server: @qatjs/server, @qatjs/sync-server;
    • for development: @qatjs/devtools, @qatjs/devtools-panel, @qatjs/test, @qatjs/graph, @qatjs/schemas;
    • the tooling: @qatjs/compiler, @qatjs/toolchain (the qatjs command), create-qatjs, @qatjs/language, @qatjs/typescript-plugin, @qatjs/eslint-plugin, @qatjs/prettier-plugin.

More

  • why.md — the measured numbers: size, dev, migrate, federation, scale
  • reactivity.md — signals, deep state, the closure rule, lifecycle guarantees
  • runtime.md — every runtime function with an example
  • components.md — children, slots, compound components
  • events.md — modifiers, gestures, events as signals
  • styling.md — scoped <style>, the class: and style: directives, compile-time checks
  • tsx.md — Qat without .qx
  • state.md — store(): actions, persist, cold fields, versions
  • router.md — routes, layouts, guards, params, typed links, keep
  • form.md — form(schema): validation, values, submit
  • head.md — <Head>: title, meta and link tags
  • backend.md — qatjs api's typed client, forms from the contract, permissions, messages
  • dev.md — qatjs init, qatjs dev, HMR, env, plugins, stylesheets
  • testing.md — what one action updates, golden states, invariants and exploration, impact in pull requests
  • debug.md — a bug end to end: explain, snapshot, replay, test
  • compress.md — qatjs compress, qatjs preview
  • virtual.md — 100,000 rows with nodes only for those in view
  • datagrid.md — DataGrid's options (reorder, pin, group, facets, CSV…)
  • load.md — load, paged lists, optimistic stores, retries, a TanStack QueryClient
  • optimization.md — what the build does on its own, from a profile, and what you ask for
  • server.md — server rendering: render modes, load on the server, deploying
  • federation.md — shells, remotes, React remotes, developing a remote
  • migrate.md — qatjs migrate and --audit; what each React construct becomes
  • collaboration.md — shared documents, the relay, live loads
  • secrets.md and vault.md — secrets in the page, device-encrypted stores
  • security.md and threat-model.md — what the build enforces, what Qat claims and does not
  • graph.md — the program graph
  • vitals.md — field Web Vitals per route
  • scale.md — a 100,000-line app: build, dev, HMR
  • browsers.md — browser support
  • packages/qat/DESIGN.md — how the reactive graph works
  • DECISIONS.md — every open spec point and how it was resolved
  • CONTRIBUTING.md, SECURITY.md