Open andyrichardson opened 5 years ago
Hey @andyk2177!
The way we've currently been doing things in urql has been through the use of state mutation on the server-side render. I'm happy to take this approach or an alternate one if you have suggestions.
If you're able to create a PR / example with a getInitialProps
implementation, I'll take a look some time this week :+1:
Oh wow useImmediateState
looks interesting! So we still need to await the fetch requests somewhere though right?
@andyk2177 yup! There's two ways I'm thinking we can approach this:
Any objections to either?
@andyk2177 no objections from me on either one. Does next.js really support SSR suspense right now though or is that in the pipeline?
@andyk2177 v0.6.0 has just been pushed with support for persistence/initial cache.
Let me know how you get along with SSR!
@andyrichardson so I'm trying to think of the best way to do this with Next.js. I think I would have to create the<TippleProvider>
on each page and fetch any data I want in getInitialProps
and pass the fetched data into the initialCache
? Does that sound about right or am I way off here? Would be nice if we only had to create <TippleProvider>
in one location like pages/_app.js
.
I'm starting to think what I want is basically Apollo's getDataFromTree
to walk the component tree, await all fetch requests generated by Tipple, and then initialize the cache with the fetched data server side. I wonder how hard that would be to implement or if there is an easier way...
@andyk2177 No worries, I'll spend some time over the weekend getting a next.js implementation set up.
@andyrichardson you're amazing! Sorry I'm making more work for you here. Am I just thinking about this all wrong? I feel like I might be missing something...
@andyk2177 nope what you're asking for makes total sense!
The 0.6.0 addition allows for SSR via injection but I'm unsure if the client fetching data will work with next.js. Once I get around to adding suspense support it should be much easier.
Ok great! Yeah, I'm really excited about Suspense! Seems like it will make things much easier.
Hey Andy, thanks for this really cool library! Do you have any idea how you're thinking about implementing SSR support for Tipple right now? I've read Suspense will eventually allow for SSR hooks but I was wondering if there might be a workaround for now. Specifically, I would like to use this with Next.js. I was thinking it might be possible to inject Tipple with initial data fetched in Next's
getInitialProps()
? It would be great to know what you think of that idea!