SSR and suspense (Vue & Nuxt) #4870
-
Hi, As far as I understand from docs (SSR & Nuxt and For example: <script setup lang="ts">
const { data, suspense } = useQuery({ queryKey: ["test"], queryFn: fetcher });
await suspense();
</script>
|
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 5 replies
-
Hi, As for I have not figured out a better way to do this. If you have some suggestions that would not break when using multiple |
Beta Was this translation helpful? Give feedback.
-
Hi, How can I use queryClient in Nuxt App?I want to use queryClient to refetch some query function at other compoent.Thanks. @DamianOsipiuk |
Beta Was this translation helpful? Give feedback.
Hi,
Correct, if you do not use
suspense
orqueryClient.prefetchQuery
, thennuxt
will not wait for query to actually resolve on the server.Also please remember to set high enough
staleTime
to avoid refetch immediately after hydration.As for
suspense
. It is done this way, because you have to place all of youruseQuery
calls before the firstawait
. Otherwise you will encounter an error whereuseQuery
afterawait
does not have access to Vue context anymore.I have not figured out a better way to do this. If you have some suggestions that would not break when using multiple
useQuery
calls, i would be more than happy to implement it.