In that case, one of those calls render server component, which again is called here from the server function, it returns the stream but you don't know it's a stream, it's handled for you. Now, you can just call the server function, you don't need to decode it, and same as before, you can just render the result, it's a renderable React value. So, in 10 sec start, as we have already seen, the server functions are the boundary for requests and response of server-rendered UI. The client sends the input shape the render needs. In that example, that's just a slug, but it can be anything, so you're not sending the whole world to the server, you specify what you need.
On the server, you have a validator that validates that the data you're passing in is actually the thing you expect, if not, error is raised and you're not continuing, otherwise, the handler is called, and it will use the validated input data, in that case, it's just a slug, and it will call render server components to pass in the JSX you want to actually render. Now, as I said before, we have primitives that compose, so, in that case, since this is a server function, you can just use a middleware and apply that and move out common stuff that you typically have around a HTTP call. In that case, since this is just HTTP, really, you can set response headers, in that case, we set cache control and CDN cache control, and that means that server rendered UI will be cached by both the browser and, even more importantly, on the CDN level, which is nice for public stuff.
But it doesn't mean that you can just return a single RSC from a server function. You can actually return whatever you want, so, as this slide says, the return shape is you can return as many server components from one server function as you want to. You can also combine this with plain data as you are seeing here. So, in that example, we are kicking off the loading outside of the server components as also possible, and, based on that, we render three server components in parallel, and then we return this in combination with plain data. And, on the server, it's just uniformly the plain data next to the server components, and you all render them or compose them as you please. And that pattern is usually useful when you have multiple server-rendered regions that share the same data load, or you want to invalidate them together and want to cache them uniformly.
Comments