The Register VM Reactivity Engine for High-Performance Web

DriftJS replaces traditional Virtual DOM tree diffing and Proxy overhead with a compact 256-register virtual machine, build-time bytecode stream, and selective hydration.

$pnpm create drift@latest

See DriftJS in Action

These interactive components are hydrated selectively using Drift's native Islands Architecture without loading client runtime for the rest of the page.

Current State
0
Derived double: 0
Notice: Value is currently zero
Step size:
⚡AOT Bytecode & Register Allocation Visualizer
Source Code
<h1 class="title">Hello {name}!</h1>
Generated Bytecode
0000CREATE_ELEMENT
0003SET_ATTR
0008INTERPOLATE_TEXT
0011APPEND_CHILD
0014RETURN

Edit & Run Live

Test Drift's virtual machine directly in your browser. Edit the code below to see instant in-place DOM updates without VDOM diffing.

App.drift
Compiling...

Engineered from First Principles

Designed for microsecond responsiveness, zero memory churn, and predictable execution.

⚙️

256-Register VM

Executes compact bytecode directly across fixed registers (r0..r255), eliminating recursive stack frames and object allocations during render loops.

⚡

Zero VDOM Diffing

State changes trigger microtask updates that re-execute only the exact bytecode instructions bound to dirty variables. Updates patch DOM nodes directly in-place.

📦

AOT Bytecode Compiler

Single File Components (.drift) compile at build time into an optimized binary-like bytecode stream and static constant pool, keeping runtime footprints tiny.

🏝️

Islands Architecture SSG

Drift Static meta-framework delivers 0 kB JavaScript on static pages, hydrating interactive widgets selectively with client:load, client:visible, and client:idle.

🔄

Keyed LIS Reconciliation

List rendering with @for directive computes the Longest Increasing Subsequence to minimize physical DOM node movements, with fast-path attribute patching.

🌊

Streaming SSR and Hydration

DriftServerVM renders virtual server node trees to static HTML with comment delimiters (<!--if-->, <!--for-->), claiming DOM nodes efficiently on client hydration.

Declarative, Simple, and Fast

Write clean components combining JavaScript logic, declarative directives, and scoped styling.

Counter.drift (DriftJS Single File Component).drift
<script>
  let count = 0;
  const double = derive(() => count * 2);

  function inc() {
    count++;
  }
</script>

<section class="counter">
  <h2>Count: {count} (Double: {double})</h2>
  <button onclick={inc}>Increment</button>

  @if count > 10 {
    <p class="milestone">Milestone reached!</p>
  }
</section>
What DriftJS Compiles Under the HoodRegister VM Bytecode
// Bytecode Stream (Uint32Array)
0x01, r0, "section"        // CREATE_ELEMENT
0x05, r0, "class", "counter" // SET_ATTR
0x01, r1, "h2"             // CREATE_ELEMENT
0x07, r2, fn(scope.count)  // INTERPOLATE_TEXT [PC: 6]
0x04, r1, r2               // APPEND_CHILD
0x04, r0, r1               // APPEND_CHILD
0x01, r3, "button"         // CREATE_ELEMENT
0x05, r3, "onclick", fn    // SET_ATTR (Event handler)
0x0D, r0, cond, subMod, deps // REACTIVE_IF
0x00, r0                   // RETURN