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
suspenseorqueryClient.prefetchQuery, thennuxtwill not wait for query to actually resolve on the server.Also please remember to set high enough
staleTimeto avoid refetch immediately after hydration.As for
suspense. It is done this way, because you have to place all of youruseQuerycalls before the firstawait. Otherwise you will encounter an error whereuseQueryafterawaitdoes 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
useQuerycalls, i would be more than happy to implement it.