Bumble Jun 3, 2021

Scalable Jetpack Compose Navigation

Article Summary

Lachlan McKee from Bumble Tech tackles a critical scalability problem in Jetpack Compose Navigation that Google's docs don't address. His solution? Delegate route creation to feature modules using Dagger Hilt factories.

When building a single-activity Compose app, the standard NavHost approach forces one location to know how to instantiate every screen—creating a potential god-class nightmare. McKee developed a factory pattern that keeps navigation logic decentralized and feature modules truly independent.

Key Takeaways

Critical Insight

A factory-based navigation pattern solves Compose's centralization problem by distributing route definitions across feature modules using Dagger Hilt's automatic discovery.

The article includes working code examples and diagrams showing exactly how the factory pattern compares to Google's approach—plus a custom annotation processor that mirrors hiltViewModel().

Recent from Bumble

Related Articles