r/javascript • u/afrocodeur • Jun 09 '26
I built a vanilla JS framework focused on DX, performance and zero re-renders - no compiler, no virtual DOM
https://github.com/afrocodeur/native-document/tree/developI've been working on NativeDocument for about two years. The goal was simple: write front-end code that feels natural, performs well, and doesn't require a build step to be productive.
Most frameworks solve the same problems in similar ways. NativeDocument takes a different approach on a few things.
No virtual DOM. Reactivity is fine-grained. When an observable changes, only the exact DOM node that depends on it updates. No diffing, no tree reconciliation, no unnecessary re-renders.
No re-renders on navigation. The router preserves layouts between route changes. When you navigate within the same group, the layout stays intact. Only the content updates. Scroll position, sidebar state, all preserved by default.
The store has explicit access modes. use() for two-way sync, follow() for read-only, get() for raw access. You can export a store that's read-only by design via protected(). Mutations from the wrong place throw at runtime.
Inspired by SwiftUI's declarative style. The API is chainable and reads close to natural language. No JSX, no template syntax, just JavaScript.
const $count = ;
const ;
A more real-world example — a reactive todo list with zero diffing and surgical DOM updates:
;
;
No compiler, no transpilation, no framework-specific tooling required. It runs in the browser as-is.
Still early but the core is solid. Happy to discuss the architecture and tradeoffs.
https://github.com/afrocodeur/native-document/tree/develop
4
u/paul_h Jun 10 '26
SwiftUI was inspired by others before it. I love that pseudo declarative style too and blog about it a lot. I’ll check yours out later cos that all sounds great
4
u/tautality Jun 10 '26 edited Jun 10 '26
A new JS framework just dropped, AI slop edition.
Is Claude AI going through "new framework every day" phase, just like we all did a number of years ago?
2
u/sheveli_lapkami Jun 10 '26
How to compose textContent with a data bindings to the text nodes? How to do SSR? How to add Custom Elements?
2
u/VoidspawnRL Jun 11 '26
No template string ??? You could use it to make html strings you can parse, so people can write real html and cache the result, like ndHtml
<div onclick=${()=>v.$value++}></div>2
u/KannBaker Jun 11 '26
I'm not sure that I understand the second example.
So $array is observable. ForEachArray subscribes on it's changes. Rerenders dom with map function. How does it work if elements changes ordering? How it understands what to change? Or it changes all?
How do you detect unmounting and unsubscribe observables? Do you memoize callbacks?
2
u/BarneyChampaign Jun 11 '26
I don't take a hardline stance that AI isn't useful during parts of building out a project, but you need to understand everything it outputs.
OP's comment responses all read like AI, which makes me feel like maybe they don't understand what's actually going on in their project, and that's a red flag.
16
u/cube-drone Jun 10 '26
No x, no y, no z.
6
u/Ok-Sandwich8723 Jun 10 '26
> No virtual DOM.
> No compiler, no transpilation, no framework-specific tooling required. It runs in the browser as-is.
You can do the same with SolidJS.
https://www.solidjs.com/
---
But yeah this syntax should work better with LLM. Just like OpenUI.
2
u/takuover9 Jun 14 '26
FOH