How to reset the navigation (router) stack?

I know that v4 its still in beta but some things about the navigation docs have confused me a little.

  1. will the NavController be deprecated ? Y/N ?
    In the doc it says " In v4, major changes were made to navigation and routing. NavController and ion-nav have now been deprecated. They can still used, but only if an app is not using lazy loading."

  2. how i can reset the nav stack to remove the back button? i.e. setting the homepage as root

Using the router this didn’t worked:
this.router.navigate(['/auth/home'], { replaceUrl: true });

I had to use the NavController:
this.nav.navigateRoot('/auth/home');

  1. is it ok to use the Location service from angular to go back ?
import {Location} from '@angular/common';
this.location.back();
1 Like

Hello

have you got an answer for your 2nd question somehow?

Well the navigation was broken in the early beta but after a few week its becomed stabled (except the android back button bug). So nav*Root() does reset the stack now.

yeap, my question is actually about android back button.
{ replaceUrl: true } is not helping, while I guess it must…

So, I will switch to navCtrl.

Thanks

1 Like

Hi.
I am using ionic version 5.4.15 and {replaceUrl: true} does it for me. It navigates to the target location and clears the browsing history as well.

Please try to update your ionic to the latest version.

Hope it help