What is best way to compose queryFn options for server and client in SSR
Just want to know what pattern you guys follow for queryOptions that will work and client and server while preloading.
For example If I am preloading query on server it should call database directly and on client it should fallback to api route
3 Replies
eastern-cyanā¢17mo ago
interesting problem
š
you need to dehydrate when returning from the server, by dehydrating the state on the server and hydrating it on the client, you avoid the need to refetch the same data again on the client-side :thumbs_Up:
since itll be transferred to theclient cache
rare-sapphireOPā¢17mo ago
I wonder if bundler will eliminate server related modules in client bundle using this approach
eastern-cyanā¢17mo ago
if ure using app router this wont work
get server side props
..