Killing the BaseFragment: How to Build Truly Reusable Screens in Jetpack Compose

https://hackernoon.imgix.net/images/i1AvZtGMJOZiXVkqNJWdPxDMN9c2-fea342m.png
You spent years building a solid BaseFragment. Loading states, error handling, analytics hooks — all in one place. Then Compose showed up and said: "No more fragments." So where does all that shared logic go?

If you've been writing Android long enough, you know the BaseFragment pattern like an old friend. A common abstract class that every screen extended — handling loading overlays, snackbars, auth checks, toolbar setup, and whatever else your app needed consistently across screens.

Jetpack Compose is a paradigm shift, not just a UI toolkit upgrade. There are no fragments to subclass. No lifecycle hooks to override. Just functions calling functions. So the million-dollar question becomes: how do you share screen-level behavior across your entire app without inheritance?

The answer is: composition over inheritance — and Compose was designed for exactly this.


What Were We Actually Doing With BaseFragment?

Before we design the Compose equivalent, let's be...

Copyright of this story solely belongs to hackernoon.com. To see the full text click HERE

Read more