You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The Link component from next/link has prefetch turned on by default. For pages using static generation, this includes preloaded JSON data. Currently pages wrapped by withUrql ignore this data on client side transitions. I propose that support is added to take advantage of the prefetched SSG data.
I think we'll need to test this; Personally, I don't have a huge overview of next-urql but @JoviDeCroock may know whether this will "just work". I don't think we've ever tested the prefetch behaviour, so once we see how it works we can probably test it properly. But in theory this does check out for me 👍
Summary
The
Link
component from next/link has prefetch turned on by default. For pages using static generation, this includes preloaded JSON data. Currently pages wrapped by withUrql ignore this data on client side transitions. I propose that support is added to take advantage of the prefetched SSG data.Proposed Solution
Currently if an ssr exchange already exists, withUrql ignores
pageProps.urqlState
so it doesn't get the prefetched data on a client side transition. By updating this https://github.com/FormidableLabs/urql/blob/b6890ba1b0c9fa9e99301338555ea10d602cee22/packages/next-urql/src/with-urql-client.ts#L55-L58 to restore data to an existing ssr exchange it would be possible to hydrate the client with the prefetched data.} else if (ssr) { ssr.restoreData(urqlState) }
Also, thank you for the amazing library :)! Hopefully this wouldn't break something else!
The text was updated successfully, but these errors were encountered: