New Discussion

Notifications

You’re not receiving notifications from this thread.

2025 Rails frontend solution: Phlex or ViewComponents?

6
Gems / Libraries

I'm just wondering what everyone's opinions are on the two. I've always leaned into ViewComponents, but it seems like Phlex is on the come up. What has everyone's experience been with the two as of late?

Side note, I'm a big fan of inertiajs (and wish it was something more considered by the Rails team), however, I am trying to stay closer to Rails and Ruby rather than React, Vue, Svelte etc.

I think Phlex or View Component is mostly personal preference. Phlex will be all Ruby and View Component can be a mix of Ruby classes, ERB, and sidecar Stimulus controllers contained in the same folder. Either way you go they're pretty similar.

I implemented ViewComponents in mortimer.pro first but got pretty frustrated with alle the files needed for setting up a component. With Phlex it's one class and you're away. Only issue I have with Phlex is the "buffer" but if you keep your component in the class and don't let it "stray into ERB" all is well :)

I’ve been using ViewComponent for a while and it’s been very stable, especially in bigger Rails apps where the structure helps keep things organized. But recently I tried Phlex on a small project and I do like how clean it feels with everything in pure Ruby.
I’d say if you prefer the traditional Rails view flow and ERB, ViewComponent still fits nicely. But if you enjoy writing everything in Ruby and want fewer files per component, Phlex feels pretty refreshing.

back with an update! Phlex is killing it in collusion with GPT-5.3-codex! It's a Thanksgiving trick-and-treat to tell GitHub copilot: I need a card with a search on my Product index view - and 1-2 minutes later there you go! One Product::Index, Product::Card, Product::Search, Product::Item all nicely tugged away in the views/components folder with proper unit and integration testing. "It's good to be the King" :D

Join the discussion
Create an account Log in

Learning Ruby on Rails? Join our newsletter.

We won't send you spam. Unsubscribe at any time.