Want to build a full stack in HTMX?
HTMX on Steroids.
Hyperstack is HTMX-first, paired with hyper-concurrent Go, popular Python, efficient C#, high-performance Rust, and supports all popular backend languages.
Total suite payload: ~74 KB gzipped for all 13 micro-engines combined. Zero Node.js runtime. Zero client build step.
1. The Modern Web Without JavaScript Fatigue
If you appreciate HTMX, you already understand why hypermedia is the cleanest model for the web:
HTML is the medium of state transfer, the server is the authoritative source of truth, and shipping 500 MB of node_modules just to toggle a modal is pure bloat.
Traditional HTMX leaves off when applications demand instant client-side reactivity (e.g. 60 FPS computed sliders, collaborative block locking, localized undo, and virtualized enterprise grids). Hyperstack provides these missing capabilities as zero-dependency HTML attributes.
2. Five Architectural Breakthroughs
Real engineering solutions to real production headaches β backed by computer science proofs and reproducible benchmarks.
50 Years of Broken Global Undo Solved: Element-Scoped Invertible Time-Travel
The Problem: In standard web applications, undo is global. If User A is writing in paragraph 10 while User B edits paragraph 2, User A pressing Ctrl+Z often reverts User B's edits or breaks document state.
The Hyperstack Solution: Every element with an objid maintains its own isolated delta timeline. Every mutation generates an invertible delta tuple:
Oβ»ΒΉ(O(S)) = S
When focused on an element, Ctrl+Z restores strictly that element's state in 0.02ms locally without server queries, leaving all collaborator edits untouched.
The 100,000-Row Grid Freeze Solved: O(1) Coordinate-Keyed Sparse Matrix
The Problem: Updating a single stock price in a 10,000-row React or Vue table triggers virtual DOM reconciliation sweeps, garbage collection spikes, and dropped frames.
The Hyperstack Solution: Instead of allocating multi-gigabyte dense 2D arrays, Hyperstack coordinates are indexed via sparse string keys ("row:col"). Mutating cell (942, 3) touches only that exact subscriber DOM node in 0.002ms. A live 20,000-cell matrix consumes only ~5.3 MB of RAM (~266 bytes per cell).
The Infinite Dependency Crash Solved: Kahnβs Topological Sort DAG
Chained formula dependencies (A = B + C, B = D * 2) evaluate in strict topological order using Kahn's algorithm in htmx-calc.js. 500-level deep cascades resolve in 0.15 ms. Circular references are detected in O(V + E) time and surfaced as #CYCLE! without browser freezes.
Enterprise Security Without Compromise: Zero-Eval Recursive Descent AST
Most client reactivity libraries use eval() or new Function() under the hood, violating bank and healthcare Content Security Policies. Hyperstack contains zero calls to eval or dynamic code generation. All expressions are evaluated by an internal recursive-descent AST parser.
Butter-Smooth Motion: Damped Harmonic Spring Kinematics
FLIP layout animations run on an analytical damped harmonic oscillator (mαΊ + cαΊ + kx = 0). Rapid user clicks conserve physical momentum across state changes, eliminating the visual snapping and jank common with interrupted CSS transitions.
3. Core Primitives in Hyperstack 1.0
objid & docid
Every card, cell, or block carries an objid; root spaces declare docid or sceneid. Deterministic addressing eliminates selector ambiguity for AI agents and E2E tests.
FocusMode vs EditMode
Soft presence broadcasting on focus; exclusive mutex lock on edit. Crucially, active editing bubbles lock state to containing parents to prevent concurrent structural deletions.
Photoshop Elevation 0..9
Separates planes into surface, content, manipulator, and hud. Manipulator layers automatically pass clicks through to content except on drag handles.
4. Real-World Code Scenarios & Highlights
Explore complete implementations across Go, Python, C#, Rust, and Architectural Highlights. Tabs below are powered 100% by Hyperstack signals (hx-state / hx-action / hx-show).
Collaborative Block Document (Notion / Google Docs Pattern)
<!-- Root Document Container -->
<main docid="doc_q4_plan" hy-hook="/api/doc/stream" hy-action="merge" hy-target="this" class="space-y-4">
<!-- Block 1: Addressed & Streamable Heading -->
<div objid="blk_heading_1" hx-stream contenteditable="true" class="text-xl font-bold">
1. Infrastructure Optimization
</div>
<!-- Block 2: Paragraph with Invertible State Stream -->
<div objid="blk_body_1" hx-stream contenteditable="true" class="text-slate-700">
Hyperstack eliminates client hydration waterfalls and reduces bundle size by 78%.
</div>
</main>
func handleDocStream(w http.ResponseWriter, r *http.Request) {
w.Header().Set("Content-Type", "text/event-stream")
flusher, _ := w.(http.Flusher)
patch := components.StreamPatch{
TxID: "tx_9841",
Sub: "agent_reviewer",
Dom: "doc_q4_plan",
Target: "blk_body_1",
Op: "set_attribute",
Prop: "data-reviewed-at",
Val: time.Now().Format(time.RFC3339),
Inverse: "",
TS: time.Now().UnixMilli(),
}
data, _ := json.Marshal(patch)
fmt.Fprintf(w, "event: hx-stream:patch\ndata: %s\n\n", data)
flusher.Flush()
}
@app.get("/api/doc/stream")
async def stream_doc_patches():
async def event_generator():
while True:
await asyncio.sleep(3)
patch = {
"txId": f"tx_{int(time.time()*1000)}",
"sub": "agent_reviewer",
"dom": "doc_q4_plan",
"target": "blk_body_1",
"op": "set_attribute",
"prop": "data-reviewed-at",
"val": time.strftime("%Y-%m-%dT%H:%M:%SZ", time.gmtime()),
"ts": int(time.time() * 1000)
}
yield f"event: hx-stream:patch\ndata: {json.dumps(patch)}\n\n"
return StreamingResponse(event_generator(), media_type="text/event-stream")
app.MapGet("/api/doc/stream", async (HttpContext ctx) =>
{
ctx.Response.Headers.Append("Content-Type", "text/event-stream");
var patch = new {
txId = $"tx_{DateTimeOffset.UtcNow.ToUnixTimeMilliseconds()}",
sub = "agent_reviewer",
dom = "doc_q4_plan",
target = "blk_body_1",
op = "set_attribute",
prop = "data-reviewed-at",
val = DateTime.UtcNow.ToString("o")
};
await ctx.Response.WriteAsync($"event: hx-stream:patch\ndata: {JsonSerializer.Serialize(patch)}\n\n");
await ctx.Response.Body.FlushAsync();
});
async fn stream_doc() -> Sse>> {
let stream = stream::repeat_with(|| {
let json = r#"{"target":"blk_body_1","op":"set_attribute","prop":"data-reviewed-at","val":"active"}"#;
Event::default().event("hx-stream:patch").data(json)
}).map(Ok).throttle(Duration::from_secs(3));
Sse::new(stream).keep_alive(KeepAlive::default())
}
- 50 Years of Broken Global Undo Fixed: Element-scoped undo allows editing paragraph 5 and pressing
Ctrl+Zwithout destroying a colleague's edits in paragraph 2. Reversion occurs in β€ 0.02ms via precomputed inverse deltas. - Zero Hydration Waterfalls: HTML arrives pre-rendered from your server. There is no client hydration lag, no blank flash, and zero hydration mismatch errors.
- Parent Lock Bubbling: While editing paragraph 5, containing container locks bubble upward, preventing simultaneous deletions.
- Deterministic AST for AI: Standard HTML tags with deterministic
[objid]locators prevent stale closures and hallucinated hook dependencies.
High-Velocity Real-Time Data Grid (10,000+ Cells)
<div hx-grid hx-virtual-2d hx-matrix="market_depth" hx-pinned-left="1" class="h-96 overflow-auto">
<table class="w-full font-mono text-sm">
<tbody>
<tr>
<td class="p-3 sticky left-0 bg-slate-900">BTC/USD</td>
<td class="p-3" hx-cell="0,1">$94,120.50</td>
<td class="p-3" hx-cell="0,2">$94,121.00</td>
</tr>
</tbody>
</table>
</div>
// Stream micro-delta: Ξ: ::
func streamMarketTicks(w http.ResponseWriter, r *http.Request) {
w.Header().Set("Content-Type", "text/event-stream")
flusher, _ := w.(http.Flusher)
fmt.Fprintf(w, "event: hxMatrixUpdate\ndata: Ξ0:1:$94250.00:bg-emerald-500/20\n\n")
flusher.Flush()
}
@app.get("/api/matrix/stream")
async def stream_matrix():
async def generate():
while True:
await asyncio.sleep(0.016) # 60 FPS
yield f"event: hxMatrixUpdate\ndata: Ξ0:1:$94250.00:bg-emerald-500/20\n\n"
return StreamingResponse(generate(), media_type="text/event-stream")
app.MapGet("/api/matrix/stream", async (HttpContext ctx) => {
ctx.Response.Headers.Append("Content-Type", "text/event-stream");
await ctx.Response.WriteAsync("event: hxMatrixUpdate\ndata: Ξ0:1:$94250.00:bg-emerald-500/20\n\n");
await ctx.Response.Body.FlushAsync();
});
async fn stream_matrix() -> Sse>> {
let stream = stream::repeat_with(|| {
Event::default().event("hxMatrixUpdate").data("Ξ0:1:$94250.00:bg-emerald-500/20")
}).map(Ok).throttle(Duration::from_millis(16));
Sse::new(stream).keep_alive(KeepAlive::default())
}
- O(1) Direct Memory Mutation: Cell updates mutate the target coordinate directly in 0.002ms without touching any other row or column.
- Zero Garbage Collection Pressure: Micro-deltas avoid serializing complex JSON row trees, reducing network payload by 95%.
- Compact Memory Footprint: 20,000 active cells consume only ~5.3 MB RAM (~266 bytes per cell).
2D Spatial Canvas & Diagram Layer Matrix
<div class="relative w-full h-96 bg-slate-950 overflow-hidden">
<!-- Layer 0: Background Canvas -->
<hx-layer level="0" role="surface"><div class="grid-bg"></div></hx-layer>
<!-- Layer 1: Content Node Cards -->
<hx-layer level="1" role="content">
<div objid="card_api" class="card">API Gateway</div>
</hx-layer>
<!-- Layer 2: Manipulator Handles (Passes non-handle clicks to content) -->
<hx-layer level="2" role="manipulator">
<div class="handle" data-handle="resize"></div>
</hx-layer>
<!-- Layer 9: Heads-Up Display -->
<hx-layer level="9" role="hud"><span class="badge">Online</span></hx-layer>
</div>
func RenderCanvas() components.Component {
return components.Div("relative w-full h-96 bg-slate-950",
components.HxLayer(0, "surface", "", components.Div("grid-bg")),
components.HxLayer(1, "content", "", components.Div("card", components.Text("API Gateway"))),
components.HxLayer(2, "manipulator", "", components.Div("handle")),
components.HxLayer(9, "hud", "", components.Span("badge", components.Text("Online"))),
)
}
@app.get("/components/canvas", response_class=HTMLResponse)
async def get_canvas():
return """
API Gateway
Online
"""
app.MapGet("/components/canvas", () => Results.Content("""
API Gateway
Online
""", "text/html"));
async fn get_canvas_fragment() -> axum::response::Html<&'static str> {
axum::response::Html(r#"
Auth Gateway
Online
"#)
}
- Z-Index Spaghetti Eliminated: Photoshop-style 0..9 elevation layered over 4 semantic planes (
surface,content,manipulator,hud) guarantees elements stack deterministically. - Zero Click Interception: Manipulator layers automatically set
pointer-events: nonewhile promoting.handleelements topointer-events: auto. Handles remain draggable without blocking card selections underneath. - 60% Lower LLM Token Cost: AI agents describe complex canvas overlays using standard HTML tags rather than hundreds of lines of Canvas API or React Konva wiring.
5. Architectural Comparison: React vs. Hyperstack
| Dimension | React / Next.js SPA | Hyperstack 1.0 |
|---|---|---|
| Core Architecture | Client Virtual DOM diffing & reconciliation | Server Hypermedia + Direct DOM Signals |
| Runtime Footprint | ~130 KB baseline before router, store, or UI | ~74 KB gzipped for all 13 micro-engines combined |
| First Contentful Paint | JS download β JS parse β Hydration waterfall | Sub-millisecond (Pre-rendered semantic HTML) |
| State Drift Risk | High (Client store drifts from backend database) | Zero (Server is single authoritative truth) |
| Grid Writes | O(N) component re-renders | O(1) coordinate-keyed sparse matrix writes |
| Collaborative Undo | Requires complex custom CRDT/OT wrappers | Native element-scoped invertible delta rollback |
| Toolchain & Runtime | Node.js, npm/yarn, Webpack/Vite, Babel | Zero Node.js; 100% native Go, Python, C#, Rust |
| LLM Token Usage | High (Verbose JSX boilerplate, hook wrappers) | 60β80% lower (Concise declarative HTML attributes) |
6. Automated Verification & Test Rigor
| Test Suite | Location | Coverage Scope | Result |
|---|---|---|---|
| Stream & Leasing | tests/stream.test.ts | objid provisioning, invertible deltas, lease mutex, Casbin tuple | 7/7 Passed |
| Bundle Sizes & Hashes | tests/benchmarks.test.ts | Byte-for-byte artifact lengths, SHA-256 in CHECKSUMS, 350 KB budget | 10/10 Passed |
| Go DSL Parity | go/components/stream_test.go | ObjID, DocID, HxStream, HxLayer, ValidatePatch AST constructors | Passed (1.18s) |
| Full Regression Suite | tests/*.test.ts | 21 test files: signals, FLIP physics, 2D matrix, A11y roving | 168/168 Passed (1,371 assertions) |
7. 60 Seconds to First App
<!DOCTYPE html>
<html>
<head>
<script src="/htmx-bolt.js"></script>
</head>
<body class="p-8">
<div hx-state='{ "count": 0 }'>
<span hx-text="count">0</span>
<button hx-action="count = count + 1">+</button>
</div>
</body>
</html>
go run server.go
uvicorn main:app --port 8080
dotnet run
cargo run
bun run server.ts