Building a framework-agnostic Ruby gem (and making sure it doesn't break)

Ruby Native aims to be the little library that could: one gem, three UIs. It has been reported that Joe Masilotti built the project to support ERB, React, and Vue without rewriting the native side for each framework. The real test came when he added a native navbar — could a single approach ship the same behavior across three very different developer expectations? Spoiler: the answer hinged on one stubbornly simple decision.
It's HTML all the way down
Rather than couple the native app to Rails helpers or React components, Ruby Native renders hidden HTML "signal" elements with data-native-* attributes. The native app watches the DOM (a MutationObserver, in plain speak) and translates those hidden divs into real UIKit. That tiny contract — produce the right DOM, and the native layer will do the rest — proved powerful. When React and Vue support arrived, the native code didn't need to change; only new ways to emit the same HTML were required.
Let each framework feel like home
Masilotti kept the framework bindings thin and idiomatic: ERB gets blocks and builders; React gets components and props. The React components, for example, are essentially pure attribute mappers — no state, no effects, just functions that turn props into data attributes. The payoff is obvious: each API feels right to its consumers, and there’s less framework-specific logic to break. It has been reported that he also leans on automated iOS tests to catch regressions — allegedly running UI checks that ensure the native app still reads and renders those signal elements correctly before features ship.
There’s a clear lesson for multi-platform toolmakers: pick a small, stable contract and make adapters thin. Not glamorous, but effective. And when the emotional moment arrives — that first feature that could have slammed the whole approach — the simplicity of “HTML output equals native UI” held up. Who wouldn’t want that kind of safety net?
Sources: masilotti.com, Hacker News
Comments