DEV Community

Cover image for How to deploy Rails 8 + Hotwire apps on Railway
jtmst
jtmst

Posted on

How to deploy Rails 8 + Hotwire apps on Railway

Rails 8 and Hotwire make real-time UI updates incredibly simple, but deploying them usually means wiring up Redis, Postgres, Action Cable, and Rails yourself. We can use the Railway template system to simplify all of that and get up and running faster.

Use this template to deploy to railway

What you get:
The template above spins up three services

  • Rails 8.1 with Turbo Streams and Stimulus
  • PostgreSQL
  • Redis for Action Cable pub/sub

This template pre-wires everything together. ENV variables and networking have already been configured, along with Tailwind and a working broadcast demo so you can see how Hotwire works with streams right away.

Deploy Steps:

  1. Click this deploy button
  2. Sign in or create Railway account
  3. Wait for build (2ish minutes)
  4. Click the generated URL

To test the broadcast functionality, open the link in two separate browser tabs. Enter a message in one tab, and see that it instantly displays in the other tab without refresh.

This is the power of Turbo streams. A relatively simple config allows the server to broadcast HTML to every connected client

How to customize:
The template here is just the basic wiring. To customize and get started on your own real time application you'll want to fork, clone, and build on top of it:

  1. Fork the source repo
  2. Clone it locally
  3. Make your changes and customizations
  4. Push to your fork
  5. Connect railway to your repo and deploy

Use cases:
If you're new to Rails or Hotwire, here are some project types well-suited for this template

  • Real-time dashboards
  • Chat features
  • Live notifications
  • Collaborative/Multiplayer UIs

Links

Top comments (0)