But at the time we also got a lot of requests about this, uh, weird Next.js app router and honestly at this point I hadn't played with it. And I thought, yeah, okay, let's try it out.
And here we come to the point where I have to say something about my slides. These slides are a Next.js app router app. Everything we will see here is not a video, but it is actually the application and me doing super dirty tricks to show you what's happening on the server and what's happening on the client at the same time.
So we go into our next slide, that slide is going to use users Ben's query and hopefully, uh, yeah, hopefully the conference network is there and that request will finish at some time. Um, Of course it doesn't, uh, no, no. Yeah, perfect. Perfect. Uh, so like we had one fetch in the browser of that's fine, right? Uh, and I was really happy. Like we're done here. We don't have to do anything extra to support, uh, to support the app router and then I refreshed the page.
And after we refreshed the page, let me go back to full screen. Suddenly that same request happens on the server and in the browser. And this is also something that is really irritating me. Uh, like, especially since I drafted these slides, uh, they run at the same time, like all the experiments I did in the past, they would run on the server, the server would finish and then they would run on the client. But apparently I found the edge case of reproduction here to have a component rendering, both environments at once. I'm going to be debugging that for weeks from now.
Um, but the main problem is the same. The component runs in both places and it fetches data in both places. And actually that data isn't even transported from the server to the browser, so the server makes a request and throws it away and nothing good comes out of it. So obviously that's not a good thing. So suddenly we are in SSR territory. We wanted to do that at a later point in time. We don't have a chance to do that at a later point in time. We have to do it now. So the first thought of course is let's do SSR as we've always been doing SSR. Let me refresh the page though that loading state at the bottom goes away because that's my hack to make that data transport over.
Um, so SSR in the old world was like before the React tree is actually rendered, so in Xjs it would be like in get server-side props or something like that, we hook in, we execute our own code that means we create an Apollo client instance, we execute get data from tree, uh, which renders that component with an Apollo provider outside of it and passes that client instance in, that one would render the whole tree, trigger all data fetching inside that tree, give us like a promise that we can await until all the loading in there is finished. And then we repeat that, that actually happens internally in get data from tree.
Comments