← Sun, Sep 6 digest

Vidact – a compiler that turns React into direct DOM operations

read article ↗ hn thread ↗

summary

Vidact is a build-time compiler that transforms a subset of React 19 function components into optimized Vanilla JavaScript. By executing component bodies only once during the initial mount and targeting only specific DOM nodes for updates, it eliminates the need for a heavy runtime and virtual DOM diffing. This approach reduces bundle sizes and improves performance by shifting the logic from the browser to the build process. The system ensures stability by strictly forbidding unsupported React APIs at compile time rather than failing at runtime.

key points

  1. The compiler maps state updates directly to the specific text nodes and attributes that rely on that state, bypassing the traditional virtual DOM reconciliation process. This ensures that state changes cause minimal DOM mutations and zero component re-calls after the initial mount.
  2. Vidact Start extends this core compiler to provide a full-stack framework featuring file-based routing, server-side rendering, and hydration. Because the server and client share the same component description, the resulting markup and hydration process are perfectly synchronized.
  3. The tool enforces a strict subset of React 19, explicitly blocking class components and incompatible third-party libraries during the build process. This prevents the silent degradation of application behavior and forces developers to write code that is guaranteed to be compilable to vanilla JS.

who should read it

Web developers and software architects who want the developer experience of React but the performance and bundle size of vanilla JavaScript. It is particularly useful for those building high-performance sites where minimizing runtime overhead is critical.

discussion mixed

consensus

Commenters generally view the project as an interesting experiment in reducing React's runtime overhead by compiling JSX into direct DOM mutations, similar to Svelte's philosophy. While there is technical curiosity about its viability, there is significant criticism regarding the project's landing page, which users found to be sloppy and overly reliant on LLM-generated content. Most agree that the author's detailed technical explanation in the comments is far more valuable than the current website copy.

top insight

The project leverages the React Compiler's analysis infrastructure (AST/scope/HIR/CFG/SSA) to map dependencies and generate static update functions, effectively replacing React's runtime model while keeping its programming model. This approach allows state changes to trigger direct DOM mutations instead of the traditional render-reconcile-mutate cycle. The author intentionally makes the project a subset of React, failing compilation for unsupported behaviors to avoid silent performance degradation.

Generated by an LLM from the article and thread. Check the sources before relying on it.