Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Navigation Duplicated in Nuxt.js

In my project I set up a simple nuxt2 with routing but when page refresh it show the error
NavigationDuplicated: Avoided redundant navigation to current location: "/haendler-details/1404-distilled-gin"

>Solution :

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

The error message you’re seeing, "NavigationDuplicated: Avoided redundant navigation to current location," typically occurs in Nuxt.js when you try to navigate to the same route that you’re already on. This error is thrown by Vue Router, which is the routing library used by Nuxt.js.

To avoid this error, you can use one of the following approaches:

1.Use the router-link component with the exact prop:

<router-link to="/haendler-details/1404-distilled-gin" exact>Go to Distilled Gin</router-link>

2.Catch the NavigationDuplicated error and handle it gracefully:

// In your main.js or equivalent
import Vue from 'vue';
import VueRouter from 'vue-router';

const originalPush = VueRouter.prototype.push;
VueRouter.prototype.push = function push(location) {
  return originalPush.call(this, location).catch((err) => {
    if (err.name !== 'NavigationDuplicated') {
      throw err;
    }
  });
};

// In your component
this.$router.push('/haendler-details/1404-distilled-gin');
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading