Prevent back route navigation for specific page

It is possible to prevent back route navigation executed from hardware backbutton on specific page ?
In case, for example, when i would like to initialize additional function before navigate back. So, hardware backbutton must be clicked few times for a back route. But only on specific page. All other pages must works normal.

Ionic with React in use.

If you’re using Angular, you can use an AuthenticationGuard.

Here’s a random article I got from searching:

https://medium.com/@ryanchenkie_40935/angular-authentication-using-route-guards-bf7a4ca13ae3

If you don’t wanna do that, you can just register an override for the back button in your page, do something custom then call navigate back in your code.

The Ionic docs have this all mapped out both for Capacitor and Cordova.

Which method you use to override the back button (if you choose to do so) will depend on what native container you’re using.

1 Like

Thank you, interesting especially in React case.