A compile-time reactive web framework for Nim.
Experimental · Design PhaseNexum generates fine-grained DOM updates at compile time using Nim's macro system. No virtual DOM. No diffing algorithm. Just precise, signal-driven mutations emitted directly from your templates.
The same component code compiles to both a C server binary emitting HTML strings and a JS client bundle mounting real DOM.
Templates are parsed into IR and lowered to imperative DOM or string-builder code at compile time.
Signal reads auto-track dependencies. Effects rerun only when their sources change, Solid.js-style.
One source file, two backends. SSR emits HTML; the client hydrates only the islands you mark.
Unmarked components ship zero JavaScript. Only island-marked components are sent to the browser.
Nexum templates look like HTML but compile to zero-overhead DOM operations.
let count = signal(0)
proc Counter(): auto =
buildHtml:
button(
onclick = proc(ev: Event) = count.set(count() + 1)
): "Clicked " & $count() & " times"let name = signal("")
proc Greeting(): auto =
buildHtml:
input(
type = "text",
oninput = proc(ev: Event) =
name.set($ev.target.value)
)
p: "Hello, " & $name()let show = signal(true)
proc Conditional(): auto =
buildHtml:
if show():
p: "Visible!"
else:
p: "Hidden"
for i in 1..3:
li: $iThree stages. Three layers. One source file. Two compiled outputs.
buildHtml DSL is parsed into an intermediate representation at compile time.
The analyzer detects dynamic text, attributes, events, and islands.
Backend-specific codegen emits DOM code (JS) or string builders (C).
@component · @page · buildHtml · Signal
Parser → Analyzer → Codegen (Client / Server)
Signals · DOM Runtime · SSR Renderer · Hydrator
The parser transforms the buildHtml DSL into an intermediate representation. The analyzer detects dynamic text, attributes, events, and islands. Backend-specific codegen emits either DOM creation code (JS) or fast string-building code (C). Components marked with @island are emitted with hydration markers so the client only rehydrates the interactive parts.
Compile-time codegen eliminates the runtime overhead that other frameworks carry.
| Runtime | VDOM | SSR | Hydration | Lang | |
|---|---|---|---|---|---|
| React | ~40 KB | Yes | Yes | Full | JS |
| Vue | ~30 KB | Yes | Yes | Full | JS |
| Svelte | ~5 KB | No | Yes | Full | JS |
| Solid | ~7 KB | No | Yes | Full | JS |
| Nexum | 0 KB | No | Yes | Islands | Nim |
nimble install nexum
proc greeting(): auto =
buildHtml:
h2: "Hello, Nexum"echo greeting() # →Hello, Nexum