I’m working on a Nuxt 3 project, and I’m experiencing an issue where NuxtLink components are not redirecting properly. Clicking on a NuxtLink does not navigate to the desired route, but using a classic tag works without any issues.
What I’ve Tried:
- Verified that the routes exist in the pages/ directory.
- I checked the browser console and found the following warnings:
[Warning] Timer "[nuxt-app] page:loading:start" already exists
[Warning] Timer "[nuxt-app] page:loading:end" already exists
- Disabled pageTransition in nuxt.config.ts:
pageTransition: false
This did not resolve the issue.
- Cleared the .nuxt directory and rebuilt the app:
rm -rf .nuxt
npm run dev
- Tested with a minimal example:
<template>
<NuxtLink to="/about">Go to About</NuxtLink>
</template>
The issue persists.
Relevant Code:
Here’s my nuxt.config.ts file:
export default defineNuxtConfig({
compatibilityDate: "2024-11-01",
runtimeConfig: {
public: {
GOOGLE_ANALYTICS: process.env.GOOGLE_ANALYTICS,
CHATWAY: process.env.CHATWAY,
},
},
css: ["/assets/css/main.css", "primeicons/primeicons.css"],
devtools: { enabled: true },
debug: true,
modules: [
"nuxt-swiper",
"@nuxtjs/tailwindcss",
"@primevue/nuxt-module",
"@nuxt/icon",
"@nuxt/fonts",
],
app: {
baseURL: "/",
buildAssetsDir: "/_nuxt/",
head: {
link: [
{
rel: "icon",
type: "image/x-icon",
href: "https://example.com/img/Favicon-2/height=100",
},
],
title: "Nuxt App",
charset: "utf-16",
viewport: "width=device-width, initial-scale=1, maximum-scale=1",
htmlAttrs: {
lang: "en",
},
},
pageTransition: { name: "page", mode: "out-in" },
},
nitro: {
output: {
publicDir: "dist",
},
},
});
I am not using any custom middleware.
The issue occurs across all pages.
Using tags works fine, but I want to use NuxtLink for client-side navigation and better performance.
What could be causing NuxtLink to fail while tags work? How can I debug or fix this issue?