As described in the reproduction, the new version of nuxt3 changed the behaviour of useAsyncData.
In Version 3.0.0-27379487.e0cf2d7useAsyncData was only called server side if the page was directly opened in the browser. Only when navigating from another nuxt subpage with the NuxtLinkuseAsyncData was called in the browser and not in the server.
This behaviour is sensible to me. However in Version v3.0.0-27444404.919db5b of nuxt this changed. Not on a direct page load first useAsyncData is called and after that it is called on the client as well.
Additional context
What i do in the function useAsyncData is to load data either directly from the database if the code is executed on the server and to load the api from an api if the code is executed in the browser. And i don't want the code to be executed two times.
Environment
Nuxt CLI v3.0.0-27444404.919db5b 16:17:26 RootDir: /Users/david/projects/finder/churchtools-finder 16:17:28 Nuxt project info: 16:17:28
Darwin
v16.13.2
3.0.0-27444404.919db5b
npm@8.1.2
Vite
publicRuntimeConfig
,css
,build
,serverMiddleware
,privateRuntimeConfig
-
Build Modules:
-
Reproduction
I have a file
test.vue
in the pages folder. It looks like this:When calling http://localhost:3000/test in the browser i see the following:
Nuxt Version
v3.0.0-27444404.919db5b
server1
client1
client1
Nuxt Version
3.0.0-27379487.e0cf2d7
server1
server1
Describe the bug
As described in the reproduction, the new version of nuxt3 changed the behaviour of
useAsyncData
.In Version
3.0.0-27379487.e0cf2d7
useAsyncData
was only called server side if the page was directly opened in the browser. Only when navigating from another nuxt subpage with theNuxtLink
useAsyncData
was called in the browser and not in the server.This behaviour is sensible to me. However in Version v3.0.0-27444404.919db5b of nuxt this changed. Not on a direct page load first
useAsyncData
is called and after that it is called on the client as well.Additional context
What i do in the function
useAsyncData
is to load data either directly from the database if the code is executed on the server and to load the api from an api if the code is executed in the browser. And i don't want the code to be executed two times.