Skip to main content
BackHandler is Android-only. On iOS, it has no effect.
The BackHandler API detects hardware back button presses on Android devices, allowing you to control back button behavior. Event subscriptions are called in reverse order (last registered first), and if one subscription returns true, earlier subscriptions won’t be called.

Import

Methods

addEventListener()

Adds an event listener for hardware back button presses. Parameters:
  • eventName: Must be 'hardwareBackPress'
  • handler: Function that returns true if it has handled the back press, false or null/undefined otherwise
Returns: An object with a remove() method to unsubscribe the listener.

Example

exitApp()

Programmatically invokes the default back button functionality to exit the app.

Example

Usage Example

Notes

  • BackHandler only works on Android. On iOS, it’s a no-op.
  • Event handlers are called in reverse order (LIFO - Last In, First Out).
  • If a handler returns true, earlier handlers won’t be called.
  • If no handlers return true, exitApp() is automatically called.