Mercari's NavEntryScope: The missing scope in Android Hilt
Original post NavEntryScope: The missing scope in Android Hilt
Article Summary
Luca from Mercari's Android team just solved a problem that's been plaguing Hilt users for years: how do you share dependencies across multiple ViewModels on the same screen without leaking data everywhere?
When Mercari's logistics team needed multiple ViewModels to share data on their Transaction screen, they hit Hilt's scoping limitations hard. Singleton scope leaked data across navigation backstack screens, while ViewModelScope prevented sharing entirely. Their solution? Build a custom NavEntryScope and release it as an open-source library.
Key Takeaways
- Hilt's built-in scopes force awkward workarounds for multi-ViewModel screens
- NavEntryScope creates screen-level dependency sharing with automatic cleanup
- Custom component bridges ViewModelComponent using SavedStateHandle and EntryPoints
- Annotation processor eliminates boilerplate for each scoped dependency
- Library available on GitHub with working samples
Mercari created NavEntryScope to enable proper dependency sharing within a single navigation entry, eliminating manual data flow management and preventing cross-screen leakage.
Continue reading
This page summarizes “NavEntryScope: The missing scope in Android Hilt” by Mercari, published Jan 13, 2026. All credit for the original work goes to the authors.