vue-query-nuxt icon indicating copy to clipboard operation
vue-query-nuxt copied to clipboard

Question: Support SSR

Open offizium-berndstorath opened this issue 1 year ago • 2 comments
trafficstars

Describe the feature

Does this support SSR?

In the SSR & Nuxt Docs. It uses onServerPrefetch to support SSR.

Is this needed with this plugin? Or even supported?

Additional information

  • [ ] Would you be willing to help implement this feature?

offizium-berndstorath avatar Apr 22 '24 12:04 offizium-berndstorath

Hello @Hebilicious, would you confirm that plz, thanks in advance

aabumeis avatar Jun 16 '24 21:06 aabumeis

https://github.com/Hebilicious/vue-query-nuxt/blob/c6f88bc1a61e04870e0ebd93ba600f2bb85e0932/packages/vue-query-nuxt/src/runtime/plugin.ts#L17-L23 is similar with https://github.com/TanStack/query/blob/51d3e8f0cb568bb382a17490ece2b852616c6830/docs/framework/vue/guides/ssr.md?plain=1#L39-L46

So you do need:

const { suspense } = useQuery(...);
onServerPrefetch(suspense);

Or using useFetch()/useAsyncData() from nuxt which handle SSR automatically in combine with vue-query(replacing $fetch() in query function), but it will cause hydrate mismatch: https://github.com/Hebilicious/vue-query-nuxt/issues/46

n0099 avatar Jun 21 '24 21:06 n0099

Thanks for answring @n0099, I think this might be worth adding to the README.

Hebilicious avatar Dec 09 '24 19:12 Hebilicious