So the idea is we do the server request, we still do that initial render on the server, but then we don't need to send the whole application to the client and re-render the whole thing again. We can do what we call partial hydration. So if the bundle knows which components are dynamic, it only needs to send those dynamic components to the client and only those need to get hydrated and get their dynamic stuff injected.
Now this visualization might look very similar to what we had in the jQuery and Ajax days, right? Because fundamentally, it's still trying to do the same principle where we're just much more selective about what we want to do with the JavaScript and where we need JavaScript. And this is where the internet and Google fashion started mocking the idea a little bit by saying, ah, okay, so a component is just PHP. Ooh, the nice tree occurred on top of it. And that we're evolving, but backwards.
All of this is to say, this kind of solves the hydration thing with partial hydration, that JavaScript that we need to download is much smaller, the hydration itself is much smaller and much quicker, but it doesn't really solve the second problem. So if the server does a lot of work and the server response, the initial server response is really slow, how do we fix that?
Now, to understand that, we'll build a solution from scratch, like a very simplified solution from scratch ourselves. And for that, we're going to look at traditional server-side rendering and where that brings us. Then we'll look at some stuff like classical streaming and some of the limitations that come with it. And finally, we'll take a look at how auto-streaming kind of addresses those final limitations and what all of that gives us from a DX perspective, but also from a user experience perspective. All right. Let's write some code.
For that, I prepared a small demo application. It's fairly simple. It's just a kind of movie or TV show app where you can look at a TV show, see some details about it, what the plot is about, see details about the cast, and maybe some similar movies and TV shows that you might like if you like this one. It's called Notflix. I don't want to get sued. But you can see if you look at the code for this, I also tried to keep it fairly simple. So this is just an Express app. Express doesn't really matter here. It's just the simplest service setup.
And we're rendering individual components here for the different sections of the application. So we have one component for the header, one component for the title, image, and details, then one component for the cast, and one component for the simpler movies. If we look at those components, you can see that they look mostly like regular React components.
Comments