Amazon Developer

as

Settings
Sign out
Notifications
Alexa
Amazon Appstore
Ring
AWS
Documentation
Support
Contact Us
My Cases
Get Started
Design and Develop
Publish
Reference
Support
Skip to main content
The Backhandler API detects hardware button presses for back navigation, lets you register event listeners for the system’s back action, and lets you control how your application responds. The event subscriptions are called in reverse order (i.e. the last registered subscription is called first).
  • If one subscription returns true, then subscriptions registered earlier will not be called.
  • If no subscription returns true or none are registered, it programmatically invokes the default back button functionality to exit the app.
React Native for Vega Application process termination characteristics:
  • In the case of multiple interactive components, only the interactive component is terminated not the entire React Native for Vega Application process.
  • In the case of a singleton component or there is only once interactive component instance active, then calling exitApp terminates the entire React Native for Vega Application process since there are no other interactive components left.
In the case of multiple interactive components, the back button functionality only terminates the interactive component, not the entire React Native for Vega Application process. If your interactive component is a singleton or there is only one interactive component instance active for your React Native for Vega Application process, then calling exitApp terminates the entire React Native for Vega Application process since there are no other interactive components left. Warning for modal users: If your app shows an opened Modal, BackHandler will not publish any events, see (Modal docs).

Pattern

Example

The following example implements a scenario where you confirm if the user wants to exit the app:
BackHandler.addEventListener creates an event listener & returns a NativeEventSubscription object which should be cleared using NativeEventSubscription.remove method.

Usage with React navigation

If you are using React Navigation to navigate across different screens, you can follow their guide on Custom Android back button behaviour

Backhandler hook

React Native Hooks has a nice useBackHandler hook which will simplify the process of setting up event listeners.

Reference

Methods

addEventListener()


exitApp()


removeEventListener()

Last modified on December 10, 2025