Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Rails needs more opinionated decision on frontend story. Just pick ReactJS instead ? Not a bad idea. Or VueJS ? Neither a bad choice. It's the main reason i don't choose Rails over a universal Node.js stack for the HTML rendering part.



Also, their opinion is to provide a JSON API by default, so you can hook in a JS frontend app later if you want.

If you want it right from the start, you can create an api only rails project: https://guides.rubyonrails.org/api_app.html


Yeah, Rails for API is great choice. My concern is about the HTML rendering part.


Their opinion is coffeescript + turbolinks, which turn out to be the first two defaults developers change.


I mean something like Typescript with an opinionated library/framework for client-side part.


Okay, I have lots of good news for you.

First, CoffeeScript is formally deprecated. Turbolinks sucked, but Turbolinks 5 is an entirely new beast and it rocks. You need to give it a second look. I recommend this talk, sped up to 1.5x:

https://www.youtube.com/watch?v=SWEts0rlezA&t=3m22s

Finally, there absolutely is an opinionated client library that is designed to pair beautifully with Turbolinks 5. It's called Stimulus and it rocks.

https://stimulusjs.org/

You can play with all of these frameworks using the --webpack parameter:

rails new future --skip-sprockets --skip-coffee --webpack=stimulus --database=postgresql --skip-test

As a bonus for anyone starting a new Rails project today, you're going to want to bookmark https://gist.github.com/andyyou/834e82f5723fec9d2dc021fb7b81...

Let me know if you have any questions.


Thanks, it's an almost complete guide. But there's one important missing piece: Universal routing. How about taking the routing config which can be applied for both server and client ?


If you're talking about React-style routing via navigation or whatever, then yeah, you need to evaluate what's best for you.

One reason I love Stimulus + Turbolinks 5 is that you don't have to think in terms of client-side routing.


Turbolinks works fine with VueJS.




Consider applying for YC's Fall 2025 batch! Applications are open till Aug 4

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: