by Ocha · 4y ago · 0 comments
It works really well: adding new components or iterating over existing ones is super easy, nothing is brittle, UI/UX fidelity is great and very easy to implement, minimal to no API calls (depending on what components I have on the page). Rails views are smaller and much easier to refactor too.
I've been dying to implement Vue component responses for my projects ever since I first heard about it because I believe that this is a way to keep things mostly on the backend while still preventing JS spaghetti on the frontend.
I read about https://inertiajs.com/ but it seems too overkill. I'd prefer to keep things simpler.
If you just want to use Vue for your rendering layer, you can can do that using a very minimal partial that renders the root element and loads the JS to mount the component. This example should get you started (Vue 2 syntax):
https://gist.github.com/yourboyblue/834aac9c427a97037dd49694...
There's still plenty of room for Vue/React done right when you have the staff and technical investment no doubt. For Node.js and non-Rails apps where the SSR/hydrating story for complex front-end UIs are needed then it's still very comparable and not really worth the 'paradigm shift'. Otherwise if you're on Rails with Vue you need to do it right and/or you don't mind a bit of latency and have users using Chrome/FF.
Hah, I did this with PHP and React on a pretty big project quite a few years ago now :) It works really well -- though was quite hacky back then. Gave a lovely static-server-side-rendered experience, but with the interaction and organisation of React components.