NavigationEvent is a Kotlin Multiplatform library for handling system gestures - back and forward - on all platforms. It works on Android, iOS and Desktop with Web support coming next.

Android rely on OnBackPressedDispatcher from androidx.activity. It handles back presses, and that was enough. But once you target more than Android, you also need forward navigation - like on the web.

That’s why NavigationEvent exists: one event system that works everywhere.

It’s in beta01 on Android, and OnBackPressedDispatcher already delegates to NavigationEventDispatcher under the hood.

Debugging Back State

Back handling gets messy fast. Multiple handlers register, each hoping to own the gesture. Where do you end up once back completes?

That’s what the NavigationEventInfo API answers.

Every NavigationEventDispatcher keeps a history which exposes:

  • mergedHistory: a single flattened list combining all nested navigation info.
  • currentIndex: the position of the active entry within that merged history.

Inspect these to see who’s active and what happens next.

In Navigation3, SceneInfo describes your current scene state. Similar support will come to Navigation2 once it updates to a newer compileSdk.

You’ll also find OnBackPressedCallbackInfo, BackHandlerInfo, PredictiveBackHandlerInfo, ThreePaneScaffoldSceneInfo , and others. More are coming as libraries migrate.

Custom Info

You can define your own Info to make debugging clearer in your app or library. In Compose:

@Composable
fun Sample() {
  NavigationBackHandler(
    state = rememberNavigationEventState(info = YourCustomInfo()),
    // ...
  )
}

The Bigger Picture

NavigationEvent isn’t just a new dispatcher. It’s a step toward making back and forward navigation consistent across Android, iOS, Web and Desktop.

The Info API gives you a window into that system: what’s happening, who’s in control, and where your app is heading next.

ℹ️ If you enjoyed the article you might enjoy following me on Bluesky. ℹ️