JavaScript

JavaScript

Made by DeepSource

Found usage of href with NuxtLink component JS-W1034

Bug risk
Major
Autofix

When using the inbuilt NuxtLink component to navigate between pages, use the 'to' prop instead of the 'href' attribute that is generally used with the HTML <a> tag. Internal links can then be routed to using optimizations such as pre-fetching. Using 'href' with NuxtLink can lead to unintended bugs and minor performance issues.

Bad Practice

<template>
  <NuxtLink href="/home">Home</NuxtLink>
  <NuxtLink href="/about" to="/about">About</NuxtLink>
  <NuxtLink href="/about" :to="`/product/${id}`">Product</NuxtLink>
</template>

Recommended

<template>
  <NuxtLink to="/home">Home</NuxtLink>
  <NuxtLink to="/about">About</NuxtLink>
  <NuxtLink :to="`/product/${id}`">Product</NuxtLink>
</template>