How to setup live code reload in Hanami and Rails

Modern web-frameworks automatically reload the browser after every change. Both Rails and Hanami won’t do this by default, so it might surprise you if you’re new to them.

However, Hanami offers fast code reloading in development via the hanami-reloader gem. When you run hanami server in development, guard watches the file system for code edits and restarts the Hanami server when changes occur. You can follow the official code reloading guide to set it up.

In Rails you can get it working by adding rails_live_reload gem to the Gemfile and running the rails server command.

2 Likes

I’m honestly not a fan of live reloading. It’s common for me to want to compare two versions of a page, so it’s annoying when it refreshes automatically without me triggering it.

That’s understandable, but I do think it’s great to have the option for those who do like it.