Building Reactive UIs Directly on the DOM

That article focused on the philosophy and architectural direction behind DOMPP. This article focuses on runtime behavior and practical usage patterns.

Illustration for Building Reactive UIs Directly on the DOM
Building software is the process of making decisions.

DOMPP Runtime Patterns and Use Cases

In the previous article, we explored the core philosophy behind DOMPP.

This article is a continuation of a previous exploration:

“What If The DOM Was Already Reactive?” What If The DOM Was Already Reactive?

That article focused on the philosophy and architectural direction behind DOMPP.

This article focuses on runtime behavior and practical usage patterns.

The proposal was not primarily about creating another framework.

It explored a different question:

What happens if the browser itself becomes the runtime abstraction layer?

Instead of:

  • virtual rendering layers
  • synthetic ownership systems
  • reconciliation engines
  • component runtimes

DOMPP experiments with:

  • direct DOM ownership
  • deterministic mutation
  • retained runtime trees
  • browser-native reactivity

But philosophy alone is not enough.

The more interesting question is:

What does this model actually feel like in practice?

This article explores runtime patterns and use cases built directly on top of DOM nodes.

Reactive Counters

A counter is one of the simplest ways to understand DOMPP’s runtime model.

const counter =
document.createElement("button")
.setState({
count: 0
})
.setText(({ state }) => {
return (
`Count: ${state.count}`
);
})
.setEvents(({ state, setState }) => ({
click() {
setState({
count:
state.count + 1
});
}
}));

Several things are happening here.

The DOM node itself owns:

  • local state
  • mutation behavior
  • event handling
  • runtime updates

There is no:

  • component instance
  • virtual tree
  • render function rerun
  • external runtime ownership layer

The node itself becomes the runtime boundary.

Reactive Children

One of the more interesting runtime patterns in DOMPP is reactive tree rebuilding.

const todo =
document.createElement("div")
.setState({
items: [
"Apple",
"Orange"
]
})
.setChildren(({ state }) => {
return [
document
.createElement("h2")
.setText(
`Items: ${state.items.length}`
),
...state.items.map((item) =>
document
.createElement("div")
.setText(item)
)
];
});

This pattern resembles declarative UI rendering.

But unlike virtual DOM systems, DOMPP does not construct a synthetic intermediate tree.

The child tree itself is mutated directly.

This creates an interesting runtime model:

DOM nodes are both:
- the rendered output
- the retained runtime structure

The browser already owns the tree.

DOMPP simply mutates it deterministically.

Reusable Stateful Elements

Modern frontend frameworks often center around component systems.

DOMPP explores a simpler assumption.

Reusable UI can emerge directly from JavaScript functions returning DOM nodes.

function createCard(title) {
return document
.createElement("div")
.setState({
likes: 0
})
.setChildren(({ state, setState }) => [
document
.createElement("h2")
.setText(title),
document
.createElement("div")
.setText(
`${state.likes}`
),
document
.createElement("button")
.setText("Like")
.setEvents({
click() {
setState({
likes:
state.likes + 1
});
}
})
]);
}

This creates an interesting architectural shift.

The reusable unit is no longer:

  • a framework component instance
  • a compiler abstraction
  • a runtime ownership object

It is simply:

A function returning a retained DOM runtime node.

Cross Element State

Because state is attached directly to DOM nodes, any other node can mutate that state through retained references.

counter.setState(({ state }) => {
state.count += 1;
});

This creates a very different mental model from centralized stores.

Ownership becomes spatial.

The state belongs to the node.

Other nodes interact with it through references.

This aligns surprisingly well with how the browser itself already models retained objects.

Existing DOM Enhancement

One of the most interesting DOMPP patterns is enhancement.

Instead of rebuilding ownership through hydration, existing DOM trees can be enhanced directly.

For example, imagine server-rendered HTML like this:

<div id="counter-app">
<h2>
Counter
</h2>
<div>
0
</div>
<button>
Increment
</button>
</div>

Rather than recreating the tree through a rendering runtime, DOMPP enhances the existing nodes directly.

document
.getElementById("counter-app")
.setEnhancement(({
childNodes,
state,
setState
}) => {
const count =
childNodes[1];

const increment =
childNodes[3];

count.setText(
state.count
);

increment.setEvents({
click() {
setState({
count:
state.count + 1
});
}
});
});

This pattern treats server-rendered DOM as an already-existing retained runtime tree.

The runtime does not need to reconstruct ownership.

It enhances ownership directly onto existing nodes.

This becomes particularly interesting for:

  • SSR systems
  • partial enhancement
  • static-first architectures
  • progressive runtime adoption

Example: https://dompp.digital/examples/13-existing-dom-enhancement/

Fine-Grained Signals

DOMPP also explores optional fine-grained reactivity.

const [count, setCount] =
document.createSignal(0);

Signals rerun only the setters that directly consume them.

document
.createElement("h2")
.setFineGrained()
.setText(() => {
return count();
});

Updates happen through:

setCount(
count() + 1
);

The .setFineGrained() call explicitly marks the node as participating in signal-based subscriptions.

This is important because fine-grained mode in DOMPP is optional rather than globally implicit.

Signals are additive.

The original stateful mutation model still works independently.

This creates an interesting hybrid runtime architecture:

  • retained DOM ownership
  • direct mutation semantics
  • optional fine-grained subscriptions

Examples: https://dompp.digital/examples/14-fine-grained-signals/

https://dompp.digital/examples/15-existing-dom-enhancement-signals/

State Equality Semantics

One interesting runtime question explored in DOMPP is:

What happens when state is updated with the same value?

For example:

setState({
count: 0
});

when the current state is already:

{ count: 0 }

Should the runtime:

  • rerun reactive setters?
  • skip updates?
  • perform equality checks?
  • mutate directly regardless?

DOMPP examples intentionally expose these semantics transparently.

Rather than hiding runtime behavior behind reconciliation heuristics, the runtime behavior itself becomes observable and explicit.

Nested Stateful Ownership

Another interesting runtime pattern involves nested ownership.

A parent node can own local state.

A child node can also own independent local state.

Parent DOM Node
└── Child DOM Node

Each node becomes its own runtime ownership boundary.

For example:

const parent =
document.createElement("div")
.setState({
title: "Parent"
})
.setChildren(() => [
createChild()
]);

Where the child owns separate local state:

function createChild() {
return document
.createElement("button")
.setState({
count: 0
})
.setText(({ state }) => {
return (
`Count: ${state.count}`
);
});
}

This creates important runtime questions:

  • What survives replacement?
  • What survives reuse?
  • What resets identity?
  • What preserves ownership?

DOMPP examples intentionally expose these behaviors directly rather than abstracting them away.

Example: https://dompp.digital/examples/17-nested-stateful-elements/

DOM Identity Preservation

One of the most important runtime concepts in DOMPP is identity preservation.

In many frameworks, identity is reconstructed indirectly through:

  • keys
  • reconciliation
  • virtual trees
  • diffing

DOMPP explores a more direct assumption:

DOM node references ARE runtime identity.

If the same node reference survives:

  • local state survives
  • event listeners survive
  • ownership survives

If the node is replaced:

  • state resets
  • identity changes
  • ownership changes

For example:

root.setChildren(
counter
);

reuses the same runtime node.

Meanwhile:

counter = createCounter();

root.setChildren(
counter
);

creates entirely new runtime ownership.

This becomes especially visible in list mutation patterns.

Example: https://dompp.digital/examples/19-dom-identity-preservation/

Keyed List Behavior

DOMPP intentionally exposes list semantics directly.

items.reverse();

list.setChildren(
...items
);

If the same DOM node references are reused, local state survives.

items = [
createItem("A"),
createItem("B")
];

creates entirely new ownership identities.

The runtime semantics become extremely explicit.

This is very different from hiding identity behind reconciliation algorithms.

Example: https://dompp.digital/examples/18-keyed-list-behavior/

Reactive Feed Mutation

One of the most practical DOMPP examples is a reactive feed.

Posts themselves are stateful DOM nodes.

const post =
createPost(text);

Prepending:

posts.unshift(post);

feed.setChildren(
...posts
);

Appending:

posts.push(post);

feed.setChildren(
...posts
);

Removing:

posts = posts.filter(
(p) => p !== post
);

Each post preserves:

  • local state
  • edit history
  • event handlers
  • runtime ownership

because the DOM node reference itself survives.

This creates prepend and append semantics without needing a synthetic ownership system.

The runtime tree itself becomes the retained ownership structure.

Example: https://dompp.digital/examples/20-reactive-feed/

Runtime Transparency

One recurring theme across all DOMPP examples is runtime transparency.

The proposal intentionally avoids hiding runtime behavior behind:

  • reconciliation heuristics
  • compiler transforms
  • ownership reconstruction
  • synthetic render layers

Instead, DOMPP attempts to expose runtime behavior directly through DOM semantics.

The goal is not necessarily less complexity.

The goal is:

More explicit runtime semantics.

Browser-Native Runtime Exploration

DOMPP is still an experimental exploration.

It is not attempting to replace the frontend ecosystem.

Instead, it explores an interesting possibility.

What if the browser itself evolved stronger runtime semantics?

What if:

  • mutation became more composable?
  • ownership became DOM-native?
  • enhancement replaced hydration in some scenarios?
  • fine-grained subscriptions existed directly on browser primitives?

Could frameworks eventually become thinner layers on top of browser-native runtime capabilities?

DOMPP explores these questions through direct DOM experimentation.

Closing Thoughts

For years, frontend architecture has increasingly moved toward abstract rendering runtimes.

DOMPP explores a different direction.

What happens if:

  • the DOM itself becomes reactive
  • ownership lives directly on nodes
  • identity is preserved through references
  • mutation becomes deterministic
  • runtime semantics remain visible

The browser already owns the rendering tree.

Perhaps the next interesting evolution is not replacing the DOM.

Perhaps it is treating the DOM itself as the runtime.

DOMPP is not a finished answer.

It is an exploration.

An attempt to ask:

What happens if the browser itself evolves stronger runtime semantics?

Explore DOMPP

Interactive examples, runtime experiments, and architecture notes are available here:

DOMPP Documentation

https://dompp.digital/

DOMPP GitHub Repository

https://github.com/dimaspandu/dompp

References

  1. MDN Web Docs — Document Object Model (DOM) https://developer.mozilla.org/en-US/docs/Web/API/Document_Object_Model
  2. MDN Web Docs — Node https://developer.mozilla.org/en-US/docs/Web/API/Node
  3. MDN Web Docs — Element https://developer.mozilla.org/en-US/docs/Web/API/Element
  4. React Documentation — Render and Commit https://react.dev/learn/render-and-commit
  5. SolidJS — Fine-Grained Reactivity https://www.solidjs.com/
  6. Incremental DOM — Google https://github.com/google/incremental-dom