A Rails template for modern, reactive applications
Tags: rails, ruby, showdev
Published: 2021-09-03 03:33:23

I've [written](https://www.colby.so/posts/live-search-with-rails-and-stimulusreflex) [a lot](https://www.colby.so/posts/turbo-streams-on-rails) [about](https://www.colby.so/posts/instant-search-with-rails-6-and-hotwire) 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](https://github.com/DavidColby/vite_starter_template) that let's me jump right into building.

This [new template](https://github.com/DavidColby/vite_starter_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:
* Ruby on Rails (of course)
* [Stimulus](https://stimulus.hotwired.dev/)
* [Turbo](https://turbo.hotwired.dev/)
* [CableReady](https://cableready.stimulusreflex.com/) + [StimulusReflex](https://docs.stimulusreflex.com/)
* [WindiCSS](https://windicss.org/)

Instead of using Webpacker to handle building JavaScript and CSS, I've added Vite, via [vite_rails](https://github.com/ElMassimo/vite_ruby), 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](https://vitejs.dev/) is a well-supported project with a very active community working to improve it.

With the decision to [move away from Webpacker](https://github.com/rails/rails/pull/42999) 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
```

## 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](https://jumpstartrails.com/).

If you have a tool that you want to see included, [Github issues](https://github.com/DavidColby/vite_starter_template/issues) and [PRs](https://github.com/DavidColby/vite_starter_template/pulls) 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](https://github.com/DavidColby/vite_starter_template).

As always, thanks for reading!