rememberTypedNavBackStack

inline fun <T : NavKey> rememberTypedNavBackStack(vararg initialKeys: T, configuration: SavedStateConfiguration = SavedStateConfiguration.DEFAULT): NavBackStack<T>

Remembers a type-safe navigation back stack across configuration changes and process death.

Unlike androidx.navigation3.runtime.rememberNavBackStack, preserves the navigation key type T and supports serializable sealed route hierarchies without explicit serializer registration. Specify the hierarchy type explicitly so Kotlin does not infer the concrete initial route type:

val backStack = rememberTypedNavBackStack<AppRoute>(
AppRoute.Home
)

Parameters

initialKeys

Initial entries of the back stack.

configuration

Optional saved-state serialization configuration.