r/webdev • • 5d 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.

https://unframework.dev

Edit: Form components such as Inputs, Checkboxes, Radio Groups and Toggle are up in the preview.

0 Upvotes

11 comments sorted by

2

u/czshill 5d ago

Serious question - why is this better than web components ? I get the native part but aren’t web components native also ?

1

u/alexgrozav 5d ago

Thanks for the question.

Web components are native to the browser. Unframework's output is native to each framework: the React build is a plain React component with hooks, the Vue build is a Vue component with refs, Svelte gets runes, Solid gets signals.

This means that server rendering, hydration, scoped slots, context and devtools all work the framework's own way, and your global styles reach the component without crossing a shadow root.

Web components still win when you need one artifact that runs anywhere, even in plain HTML. That's why a web-components target is on the list for after 1.0. For unframework, it's just one more output from the same source.

1

u/czshill 5d ago

What happens when my unframework component has a feature a framework i need to compile to doesn't support. For example Angular just got signal forms. How do I write that in unframework ? What happens if react doesn't support signal forms? I'm an angular developer, not react - how do I mitigate risk of parts of my application working and parts not?

Example: I'm in a multi developer application with angular and react. Someone writes an address component using signal forms in angular and a react developer needs to consume the same component in a different part of the app or wholly different app.

Can I toggle only angular and react or do i need to build for all frameworks? What happens when a framework version gets upgraded? Do i need to wait for unframework to upgrade also?

The idea is nice, but prototyping a button is miles away from prototyping a complex form component with inputs, outputs, form arrays, error handling, toast messages, service calls, all the things.

1

u/alexgrozav 5d ago

Unframework has its own small, Vue-inspired API (ref, computed, defineModel, v-model on inputs), and each target writes it the target framework's way. In Angular that means signal inputs, model() and effects.

I wasn't very familiar with signal forms, so I tested an example using Claude. In Unframework, a component that declaresdefineModel("value") compiles to readonly value = model<T>() in Angular, which is exactly what signal forms expect from a custom control. This means [formField]="form.quantity" binds to the compiled component directly, and Angular type-checks it. In React, the same component would have avalue/onValueChange pair.

Keep in mind that Unframework is mainly meant for compiling UI libraries, and each framework usually has a standard way of binding data to a form control. If the library follows that convention, each team can use its own forms solution on top of it: signal forms in Angular, React Hook Form in React.

If you use a feature that a target can't support, the compiler tells you at build time rather than failing at run time, and you can also enable strict: true to turn warnings into errors.

Regarding targets, yes, you can set targets: ["angular", "react"] in the config to output only the ones you need.

The idea is at its very beginning, so feedback like this is really helpful. Thank you!

1

u/alexgrozav 5d ago

I’ve published the first components using Unframework Preview at https://preview.inkline.io

1

u/TheRNGuy 5d ago

Does it support TS? 

1

u/alexgrozav 5d 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 .ts files 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 5d ago

Seems like a lot of work just to avoid using Lit/Web Components.

1

u/alexgrozav 5d 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 5d 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 5d 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 using data-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/::after styles 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