NavEaseHost

inline fun <Root : NavEaseRoot> NavEaseHost(start: NavEaseRoot, noinline onExitRequest: () -> Unit = {}, enableSharedTransitions: Boolean = false, navTransition: NavTransition = NavTransition.Push, noinline onDestinationChanged: NavEaseController.(NavKey) -> Unit? = null)

Navigation host for every @AutoRegister screen whose key belongs to the sealed root Root.

@Composable
fun App() {
NavEaseHost<AppScreens>(start = AppScreens.Splash, onExitRequest = { finish() })
}

Each host owns an independent back stack, controller and result store, so nested hosts for different roots never see each other's screens.

After a build, KSP generates a same-named overload for each of your roots. It is strictly more specific than this declaration, so NavEaseHost<AppScreens>(...) binds to the generated one, which initialises the screen registry before delegating back to NavEaseHostForRoot. This declaration exists so your code still resolves in the IDE before the first build, and so that a call which somehow misses the generated overload fails with a clear message rather than a blank screen.

Parameters

start

The key placed on the back stack first.

onExitRequest

Called when back is pressed on the root screen.

enableSharedTransitions

true to wrap the host in a SharedTransitionLayout.

navTransition

Default screen-to-screen animation.

onDestinationChanged

Called with NavEaseController as receiver whenever the top of the back stack changes, including on first composition.

Type Parameters

Root

The sealed key class whose screens this host serves.