Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

opinedals's avatar

Nuxt3 - NuxtLink calls additional fetch

Hey everyone!

I hope you're all doing great! 😊

I've got a question about something that's been puzzling me, and I’m hoping some of you Nuxt pros can help me out. I’ve recently made the jump from Vue to Nuxt and went through the classic exercise of using fetch and useFetch—just like the guide, nothing too wild.

Here's the scoop: I'm using fetch to filter some movie results on the client side—pretty straightforward. Then, I use useFetch to render the movie details page on the server side and pass it to the frontend using NuxtLink to navigate.

I've noticed something strange: When I click on a NuxtLink, I'm redirected to the movie page, and I can see it's server-rendered. But here's the catch—there's an API call in the network tab of my browser! When I refresh the page with CMD+R, there's no API call, and if I enter the URL directly into the browser, I also see no API call, even if I haven’t visited the page before. This seems to be the expected behavior, right? But the API call triggered by NuxtLink is driving me a bit nuts.

Here are some screencaptures for reference:

  • Fetch to filter results: Screencapture 1 [https://share.zight.com/Wnu8Q011]
  • NuxtLink click: Screencapture 2 [https://share.zight.com/KoukgJGK]
  • Page reload or direct URL: Screencapture 3 [https://share.zight.com/qGubQJpQ]

Is this normal? I thought being SSR meant I shouldn't see additional API calls because everything happens on the server, and then why does NuxtLink trigger a call while entering the direct URL doesn’t?

Any insights or advice would be super appreciated! Thanks a ton in advance! 🚀

0 likes
2 replies
LaryAI's avatar
Level 58

It sounds like you're experiencing an issue where navigating via NuxtLink triggers an additional API call, even though the page is server-rendered. This behavior can be attributed to how Nuxt handles client-side navigation versus server-side rendering.

When you navigate using NuxtLink, Nuxt performs client-side navigation, which means it fetches the data again on the client side. On the other hand, when you refresh the page or enter the URL directly, the page is server-rendered, and the data is fetched on the server side, which is why you don't see the additional API call.

To avoid this additional API call when navigating with NuxtLink, you can use the useAsyncData hook instead of useFetch. The useAsyncData hook is designed to work seamlessly with both server-side rendering and client-side navigation, ensuring that data is fetched only once.

Here's an example of how you can refactor your code to use useAsyncData:

// pages/movie/_id.vue

<template>
  <div>
    <h1>{{ movie.title }}</h1>
    <p>{{ movie.description }}</p>
  </div>
</template>

<script setup>
import { useAsyncData } from 'nuxt/app'
import { useRoute } from 'vue-router'

const route = useRoute()
const { data: movie } = await useAsyncData('movie', () => {
  return $fetch(`/api/movies/${route.params.id}`)
})
</script>

In this example, useAsyncData is used to fetch the movie details. This ensures that the data is fetched only once, regardless of whether the page is server-rendered or navigated to via NuxtLink.

Additionally, make sure that your API endpoint is properly set up to handle the request and return the necessary data.

By using useAsyncData, you should be able to avoid the additional API call when navigating with NuxtLink, while still benefiting from server-side rendering.

I hope this helps! If you have any further questions, feel free to ask.

opinedals's avatar

@LaryAI It didn't work, it results in the same behavior as useFetch. For additional context, I'm using an external API.

Please or to participate in this conversation.