Hacker News new | ask | show | jobs
by hijp 411 days ago
I think if Rails had focused on giving real first party support to interoperability with whatever frontend framework you brought to the table it would be so much bigger right now. They put a lot of work into Hotwire but I just want to use React, and I'm sure others want to use what they're familiar with.
3 comments

API only Rails has been a thing for a long time: https://guides.rubyonrails.org/api_app.html

Many teams use this with React.

I've built api only. It would be sick if it were easier to sprinkle react/vue/svelte/whatever in your haml views if you only needed a little bit of interaction but didn't want to spin up a whole other frontend.
I’m hardly an expert with Rails, and I integrated React twice, on two very different sites, using API controllers. The nice thing about React is that you can limit it to an island on the page, and don’t need to buy into the router, etc. that said, I did disable Hotwire to make my life easier.
Rails can be API only and use any frontend you want.

Hotwire is the default and they develop it because DHH wants to, but they're not putting up any barriers to you using whatever you want.

Also, DHH doesn't seem to care about how big it is. His stated goal is for it to forever be a framework that's usable by a single dev.

Yeah but I wish in an alternate reality DHH chose a different route. If you go API only then you lose half of what makes rails great. It would be sick if you could render React/Vue/Svelte easily in your haml views and not have to have a js repo then figure out jwts and auth.

Dunno I loved rails, built monoliths, built api only, but when I tried sprinkling a bit of react in my views (say you only need a little bit of interaction, or want to use a react date picker) then theres all these sharp edges.

The reason I want it to be bigger is that user base helps the single dev, with help resources, up to date gems, and jobs.

> but when I tried sprinkling a bit of react in my views

If you need only a sprinkling why not vanilla JS with Stimulus? Pulling in React for only a "sprinkling" seems like overkill.

The benefit of the current approach is that you can use any vanilla JS code, and it's especially easy if it uses ES Modules.

Also the whole point of React/Vue/Svelte is that they're all complete frameworks meant to do your whole UI. Using "just a sprinkling" of these seems like the worst of both worlds.

Dunno, my app pulls in a fairly heavy JS dependency (Echarts) and it took all of 2 minutes to set it up using Stimulus.