navigation-event

Implements back gesture interception and predictive back animations in Compose Android using the NavigationEvent library.

2|Updated Jun 21, 2026
One-click install
npx skills add https://github.com/IsKenKenYa/skills --skill navigation-event-iskenkenya
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: navigation-event
Source: https://github.com/IsKenKenYa/skills/tree/main/skills/android/navigation/navigation-event
Command: npx skills add https://github.com/IsKenKenYa/skills --skill navigation-event-iskenkenya

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve? Handling Android back gestures correctly in Jetpack Compose is error-prone: misconfigured dispatchers cause StackOverflowError crashes, duplicate handlers throw IllegalArgumentException, and legacy BackHandler code misses predictive back animations on SDK 36+. This Skill guides correct adoption of the androidx.navigationevent library. ## Core Features & Use Cases - Dispatcher Configuration: Uses the built-in ComponentActivity and ComponentDialog dispatcher owners correctly, and links parent-child dispatchers for ViewPagers and tabbed interfaces with rememberNavigationEventDispatcherOwner(). - Back Handling & Migration: Integrates NavigationBackHandler with predictive back progress support and migrates legacy OnBackPressedCallback/BackHandler code to NavigationEvent. - Troubleshooting Guidance: Provides RIGHT/WRONG code patterns for common failures like dispatcher recursion crashes and duplicate handler registration. - Use Case: When adding back gesture interception to a Compose screen with unsaved-changes confirmation, follow the skill to register a single unified NavigationBackHandler that branches inside onBackCompleted. ## Quick Start Ask the agent to add predictive back handling with the NavigationEvent library to your Compose screen, for example: "Migrate my Compose screen from BackHandler to NavigationBackHandler with predictive back support."

Frequently Asked Questions about navigation-event

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I handle back gestures in Jetpack Compose with predictive back animations?

Use NavigationBackHandler from the androidx.navigationevent library with a rememberNavigationEventState. It intercepts back gestures and exposes swipe progress so you can animate UI during predictive back on SDK 36 and higher.

How to migrate from BackHandler to NavigationEvent in Compose?

Replace legacy BackHandler, OnBackPressedCallback, and onBackPressed usages with NavigationBackHandler bound to a rememberNavigationEventState. Ensure compileSdk is 36 or higher and that enableOnBackInvokedCallback is not disabled in the manifest.

Why does NavigationEventDispatcher cause a StackOverflowError in my Activity?

The crash happens when you implement NavigationEventDispatcherOwner on ComponentActivity and override navigationEventDispatcher with a new instance, shadowing the library's extension property. ComponentActivity already provides the dispatcher automatically, so remove the override.

Why does NavigationBackHandler throw IllegalArgumentException?

Binding the same NavigationEventState to multiple active NavigationBackHandler instances throws IllegalArgumentException because a strict one-to-one mapping is enforced. Register a single handler and branch conditional logic inside onBackCompleted instead.

Do Compose dialogs need manual NavigationEventDispatcherOwner setup?

No. Compose Dialog, ModalBottomSheet, and any window backed by ComponentDialog automatically provide a NavigationEventDispatcherOwner. Wrapping dialog content in CompositionLocalProvider for the dispatcher is redundant.

When should I use Navigation 3 instead of the NavigationEvent library directly?

If your project already uses Navigation 3, rely on its built-in back navigation support rather than manually implementing low-level dispatchers from the NavigationEvent library. This skill is scoped to Compose Android only, not Android Views.