json
async function ProductGrid({
layout,
columns,
categorySlug,
maxItems
}: ProductGridSchema) {
// Server side data fetching
const products = await db. query({
category: categorySlug,
limit: maxItems,
status: 'active'
});
return (
{products. map(product => (
))}
);
}
In this example, the marketer controls layout, columns, categorySlug, and maxItems through the visual interface. The component fetches actual product data server side. The resulting HTML streams to the browser with zero client side JavaScript for the grid itself.
### Real World Scenarios
Consider an ecommerce team running flash sales. During high traffic events, every millisecond of load time impacts conversion rates. Traditional client side product grids fetch data after the page loads, creating a loading spinner experience and delaying time to interactive.
By implementing ProductGrid as a Server Component within the page builder, the team ensures that product data renders at build time or request time on the server. The customer receives complete HTML immediately. The only client side JavaScript is the interactive "Add to Cart" button, which imports as a lightweight Client Component.
Another scenario involves content personalization. A marketing team wants to show different hero banners based on the visitor's industry segment. With Server Components, the component can access the request headers, determine the segment server side, and fetch the appropriate content directly from the CMS. The marketer still configures the layout and styling through the visual builder, but the content selection happens automatically based on business logic the developers control.
## Comparative Evaluation
### Different Approaches Compared
Teams adopting React Server Components for page builders face architectural choices. We can categorize these into three primary patterns.
Pattern Data Fetching Marketer Control Complexity Performance Static Generation Build time</td
---
*Originally published on [Oaysus Blog](https://oaysus.com/blog/integrating-react-server-components-into-your-page-builder-component-library-a-technical-architectur). Oaysus is a visual page builder where developers build components and marketing teams create pages visually.*
For further actions, you may consider blocking this person and/or reporting abuse
Top comments (0)