Replies: 1 comment
-
@mfrachet it always depends on your use case (UI, UX, setup, etc) ofc but I'll attempt to give my 5c. I don't have a valid answer for which is best but my experience with Next.js Do not use Next.js It seems to me that these sort of reactive UIs weren't really what the Next.js team had on mind when they were building those mechanisms. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
I'm starting toying with query prefetching + useSuspenseQuery in a Nextjs app and I have to admit that my brain is having trouble trying to figure out where caching should be made and where it should be invalidated 😅 .
My main goal is to achieve very fast navigation between pages where the first load shows the suspense boundary fallback (loading.tsx) and subsequent nav (using next links) should feel instant thanks to data cached in the browser (in tanstack query). In order to do so, I'm prefetching as much as I can on the server, serialize the query client and send it back to the hydration boundray provided by tanstack query.
Now comes the cache invalidation 🤯 .
Let's say I have a table of users and one can be edited. After modifying their firstname, should I revalidate at the nextjs level (tag / path) and prefetchQuery will good enough to rehydrate the client with the updated data from the server OR should I invalidate at the client level (queryClient.invalidateQueries) OR should I do both? If both are valid, what are the usecases and which one would be the most appropriate for my goal (=== fast nav)?
I hope this question is not too dumb, and I'm very sorry if it is :(
Thanks a lot for the job achieved in this library, you awesome folks 🙏🏻
Beta Was this translation helpful? Give feedback.
All reactions