| This really resonates with something I've been working on. The article nails the core problem: we maintain JavaScript state that's just a shadow copy of what the DOM already knows. I built a library called stateless that takes this further. Instead of syncing React state with the DOM, it just reads state directly from the DOM using MutationObserver. Your HTML becomes the single source of truth. // Instead of useState + onChange + value prop dance
const [value, setValue] = useDomValue('#email', 'value');
The hook watches the DOM element and re-renders when it changes. No hydration mismatch bugs. No state sync issues. The DOM is the state.It's particularly useful for the patterns the article mentions: progressive enhancement where HTML works first, then React enhances. Your form inputs, disclosure widgets, and native elements already hold their state. Why duplicate it? stateless is part of a broader open source suite: genx for HTML generation, domx for DOM manipulation, all built on the DATAOS architecture, that together form building blocks for a hyper-efficient framework where the DOM isn't an afterthought you sync to, it's the foundation you build on Zero runtime dependencies, ~2KB gzipped: https://github.com/anthropics/stateless (or wherever it's hosted) The mental model shift is weird at first ("wait, I'm not managing state?") but once it clicks, you stop fighting the browser and start letting it do its job. |
So, I have two quick questions though, because this is where I always get nervous: - First, where do you draw the line between DOM state that is fine to trust and app state that should still live in data, like validation errors, derived values, server driven defaults, stuff that needs to be consistent across SSR and client. - Second, how does the MutationObserver part behave when things get busy. If a page has lots of inputs or updates, does it stay cheap. Do you scope it per form or per component, or is it one observer with filtering.
Either way the 2KB no deps thing is a flex, dropping a link is fair, people can decide if they want that model. I am going to skim the repo.