DEV Community

Cover image for A Rails template for modern, reactive applications
David Colby
David Colby

Posted on

A Rails template for modern, reactive applications

I've written a lot about the tools pushing Rails forward, allowing small teams of developers to build modern, fast, engaging web applications, quickly.

The stars of the show — the Hotwire stack (Stimulus and Turbo), CableReady, StimulusReflex — are now part of every new Rails application I build.

Writing Ruby code and building cool stuff is fun. Reading setup docs, fiddling with tooling, and remembering how to tie everything together each time you create a new application is a bummer.

So, to spend more time on the fun stuff and less time in setup land, I built a small Rails application template that let's me jump right into building.

This new template is now available on Github for anyone interested in building reactive Rails applications to use.

What's in the template?

The template comes with the following tools configured and ready to start using:

Instead of using Webpacker to handle building JavaScript and CSS, I've added Vite, via vite_rails, configured to work seamlessly with Stimulus and WindiCSS immediately.

Why Vite?

Vite fits in well alongside the modern, reactive stack we're using, with HMR-enabled updates for every change, including for server-side views.

In addition to being fast, simple and effective, Vite is a well-supported project with a very active community working to improve it.

With the decision to move away from Webpacker as the default Rails JavaScript setup in Rails 7, it is a good time to explore new options, and Vite is a strong contender.

Use the template

To create a new Ruby on Rails application from this template, simply run this command from your terminal:

rails new your_new_application -m https://raw.githubusercontent.com/davidcolby/vite_starter_template//main/template.rb
Enter fullscreen mode Exit fullscreen mode

Why isn't X included in the template?

I've intentionally left the template light and plan to keep it that way.

This template's goal is to provide the basic tools to build modern applications, not provide a ready-to-deploy starter application. If you want a more full-featured starter, consider Jumpstart.

If you have a tool that you want to see included, Github issues and PRs are welcome.

Wrapping up

I'd love for you to try out the stack included in this template — building Rails apps with this stack is a joy — and I hope that this template makes it a little easier to get started.

Have feedback or questions about the template? Get in touch with me here, or open an issue on the Github repo.

As always, thanks for reading!

Top comments (2)

Collapse
 
spaquet profile image
Stephane Paquet

love it.

Collapse
 
sturpin profile image
Sergio Turpín

Great article!! 👌 one day my head will explode.. 😂