Aaronmallen iconAaronmallenOct 2, 2026 ~8 min source read

Hanami, Why?: Bits & Bobs — system-level patterns you should know

A focused look at Hanami’s container-driven, file-keyed dependency system (Deps), the practical consequences of auto-registration and memoization, and the common pitfalls to watch for when building components.

Share this story

Send the public story page.

Useful takeaways from this story.

It is my intent to keep these issues focused on singular subjects whenever possible.

However, in today's issue we are going to cover several topics that are too small to warrant their own issue but still important to have for context.

The useful part

Bits & Bobs | Aaron Allen Writing Welcome back to my "Hanami, Why?" series. It is my intent to keep these issues focused on singular subjects whenever possible. However, in today's issue we are going to cover several topics that are too small to warrant their own issue but still important to have for context.

How it works

  • We have lots to cover, but this context will be important for a further understanding of how Hanami works.
  • However, in frameworks like Rails everything is autoloaded for you, so there often are not any calls to require in the code base.
  • Providers have all sorts of useful applications and are one of the many joys of working with a Hanami application.
  • Types are actually a very useful abstraction and can be used to validate and normalize user inputs.
  • Let us look at an example of a provider and how you might use one.

What to take from it

Because it is namespaced, every component it registers lives under the redis key, so the client component we will get to in a moment can be called anywhere in your application via include Deps["redis.client"]. As I mentioned, Hanami has a lot of important abstractions, and today we are going to be covering what I consider "system level" abstractions. Dependency Injection Most of the time Ruby is pretty great at telling you what a particular file depends on via require.

Example or evidence

  • You could forgo the namespace altogether, in which case you would call the dependency via include Deps["client"].
  • If you go that route, I would definitely name it redis_client instead of just client, but I hope you get the gist.
  • Remember, all of the prepare blocks are invoked before any start block is invoked.
  • So, if you have several providers, each of them will be prepared before any of them are started.

Details worth keeping

If you missed it, be sure to read Hanami, Why?: We are registering a namespaced provider named redis. We are requiring the redis gem in our prepare block.

Related coverage

  • Wrongeverytime: Hello folks, and welcome back to Wrong Every Time.
  • Hanakai: Originally appeared on Hanakai.

More context around this story.

Aaronmallen iconAaronmallenSep 30, 2026

Hanami, Why?: Introductions

Originally appeared on Writing | Aaron Allen . I mentioned in my Hello, world! post that I built this site using Hanami . This site may seem simple on the surface; it is, after all, just a blog. However, the backend is packed with features that help me day to day. I have built a tool that lets me cross-post to both Blu

Kamiina Botan – Episode 3
Wrongeverytime iconWrongeverytimeSep 11, 2026

Kamiina Botan – Episode 3

Hello folks, and welcome back to Wrong Every Time. Today we’re checking in on Kamiina and her liquor-loving dormmates, as we lounge our way through a fresh episode of Botan Kamiina Fully Blossoms When Drunk. When last we left off, … Continue reading →

Continuations 2026/36: Cobbler’s children
Timriley iconTimrileySep 8, 2026

Continuations 2026/36: Cobbler’s children

Originally appeared on Tim Riley . Feeling a lot better than last week, so I was able to do some more Hanakai work. Shared our next sponsorship drive post , thanking our silver sponsors, and bringing you a Q&A with Hanami-to-Rails porting export Carolyn Cole. Go give it a read! (And while you’re there, go sponsor Hanak

Loading more related stories...

Keep reading in the app

Open the app view to save this story, compare related coverage, and continue from the same source.

Open in app