Hardware back button with Ionic 4 Disable


Hi everyone,
How do I disable the hardware back button in android? I’ll explain. I would like the click to always remain on the same page it’s possible?


Have you tried this change in the app,module.ts?

IonicModule.forRoot({hardwareBackButton: false})

Maybe something like

const sub = this.platform.backButton.subscribeWithPriority(9999, () => {
  // Do nothing
1 Like

hi yes i’ve try but not work :frowning:


I’ve try your solution but not work, the event not fire


I am looking for how to do so only the back button material shipments on a specific page without taking into account the battery


finally I’ve found a solution, this work!!!

ionViewDidEnter() {
    document.addEventListener("backbutton",function(e) {
      console.log("disable back button")
    }, false);

For me this did work, but is there a way to restore the default functionality after using this?


I guess unsubsribe no?

if (sub) {

This is not working.

There is an openen issue on github: