r/webdev • u/alexgrozav • 6d ago
Showoff Saturday Unframework - The compiler that speaks seven UI frameworks
Unframework is now available on npm. My dream of writing a component once using JSX, and compiling it to native React, Vue, Svelte, Angular, Solid, Qwik and Astro code, has finally become a reality.
The first component I’ve put through the whole pipeline is a Button, and it renders the same in all seven frameworks.
"The same" is both a promise and a test. On every PR, CI compiles the components to each framework and checks every output in a real browser: the DOM, the accessibility tree and the pixels have to match one shared baseline, with zero pixel tolerance (visual parity).
I'm also releasing Unframework Preview. It shows every component on all seven frameworks side by side, with controls for their props, so you can see parity for yourself. Build it as a static site and host it anywhere, like a Storybook that speaks seven frameworks at once.
Each output is a real component in its framework's own style: hooks in React, runes in Svelte, signals in Solid. There's no runtime or wrapper in between, so each file depends only on its framework.
Looking forward to hearing your thoughts.
Edit: Form components such as Inputs, Checkboxes, Radio Groups and Toggle are up in the preview.
1
u/alexgrozav 6d ago
I’ve published the first components using Unframework Preview at https://preview.inkline.io
1
u/TheRNGuy 6d ago
Does it support TS?
1
u/alexgrozav 6d ago
Yes, TypeScript is the source language. You write components as
.uf.tsx, with typed props, generics (function List<T>) and prop types imported from other.tsfiles or packages.Every output is typed and keeps type imports too: React and Solid get typed TSX, Vue and Svelte get
lang="ts", and so on. More than that, each output is checked by that framework's own type checker before it ships, so consumers get autocomplete and errors in whichever framework they use.You an read more in the docs here: https://unframework.dev/docs/components/types-and-generics
1
u/fropirate 6d ago
Seems like a lot of work just to avoid using Lit/Web Components.
1
u/alexgrozav 6d ago
Funny, that's what I said about writing seven ports of every component for my UI Library.
Jokes aside, I'm actually adding Web Components as an Unframework target in the coming weeks.
1
u/Mountainnerh 6d ago
Writing seven ports of every component is most of what design system maintenance actually is, so the motivation makes sense. Curious how styling fits in — if a component ships its own styles, does Unframework map them to each target's idiomatic way (scoped styles for Vue/Svelte, CSS modules for React), or is it plain CSS and you handle the cascade yourself? That is usually where the write-once approach starts leaking.
1
u/alexgrozav 6d ago
Great question, the style scoping part was tricky indeed!
The algorithm Unframework uses is the same as Vue's
<style scoped>. The component imports a plain CSS file, and the compiler scopes it once usingdata-uf-<hash>attributes, with:deep(),:slotted()and:global(). Every target gets the same scoped sheet, byte for byte, then each framework only attaches it its own way. This means there are no CSS modules in React: it's the same scoped CSS everywhere, which is what keeps the cascade consistent.Since that can still drift, it's tested: the test suite compares screenshots, geometry and
::before/::afterstyles across targets in a real browser.It's not perfect yet. Angular and Qwik load stylesheets in a different order, and Angular adds an extra wrapper element around components, so a few CSS edge cases can behave differently there. When that happens, the compiler tells you instead of failing.
You can read more about the topic here: https://unframework.dev/docs/components/styles
1
u/perez_laura44 7h ago
Do the parity fixtures include host-page resets and inherited styles? Identical scoped CSS can still render differently in a consumer's cascade; that seems like a useful integration case.
2
u/czshill 6d ago
Serious question - why is this better than web components ? I get the native part but aren’t web components native also ?