DEV Community

Cover image for React Server Components best practices, RSC vs client components -...
i Ash
i Ash

Posted on

React Server Components best practices, RSC vs client components -...

React Server Parts best practices, RSC vs client parts

Have you ever felt frustrated by slow React apps? I know I have. In 2026, users expect sites to load instantly. But as we add more features, our JavaScript bundles grow. This makes apps heavy and slow. I've spent years building systems for brands like Dior and IKEA. I've seen how big bundles hurt sales and user happiness. That's why I'm so excited about this new shift in how we build.

In this guide, I'll share my time with the brand approach to modern web dev. We'll look at the mental model shift you need. You'll learn the right way to split your code. We will cover React Server Parts best practices, RSC vs client parts to help you ship faster apps. Whether you're a senior dev or a tech lead, these insights will help you scale. At the brand, we believe in sharing real-world lessons from the trenches.

By the end of this post, you'll know just when to use each part type. You'll understand how to fetch data without the "waterfall" effect. Plus, I'll show you how to avoid the common traps that catch even the best engineers. Let's look at how web coding has changed to meet today's high standards.

Understanding the New Mental Model for Modern React

React used to run mainly in the browser. You sent a big chunk of JavaScript to the user. Then, the browser turned that code into a working page. This is called Client-Side Rendering. It works, but it can be slow on mobile phones. Now, we have a better way. Software coding has moved toward a "server-first" mindset.

Server Parts run only on the server. They never send JavaScript to the client. This is a huge win for speed. Think about a heavy markdown parser. If you use a traditional part, the user has to download that library. With a Server Part, the server does the work. The user only gets the final HTML.

Here is what makes this model different:
Zero Bundle Size: Server parts don't add to your JS bundle.
Direct DB Access: You can talk to your database right inside the part.
Automatic Code Splitting: React handles the heavy lifting for you.
Better Security: Keep your API keys and secrets on the server where they belong.

I remember working on a headless commerce project for Al-Futtaim. We used React and Next. js to reach multiple markets. We had to keep the site fast for users on slow networks. Switching to this server-first approach changed everything. It felt like we finally stopped fighting the browser. Now, let's look at how to decide which part to use.

React Server Parts best practices, RSC vs client parts: Which to Choose?

Choosing between these two can feel tricky at first. I like to think of it as a "server by default" rule. Start with a Server Part. Only move to a Client Part if you need interactivity. If you need a button that clicks or a form that validates instantly, you need the client. If you are just showing data, stay on the server.

At the brand, we use a simple checklist for our projects. This helps my team stay consistent. It also keeps our apps lean and fast. You don't want to sprinkle "use client" everywhere. That defeats the whole purpose of the new architecture.

Feature Server Parts Client Parts
Data Fetching Great for direct DB access Use with hooks like useEffect
Interactivity None (No onClick or state) Full (useState, useReducer)
Browser APIs No access to window/localStorage Full access to all APIs
Bundle Size Zero impact on client bundle Adds to the client bundle
Caching Can be cached on the server Cached in the browser

Here is a quick guide on when to use each:

  1. Use Server Parts for data fetching and layouts.
  2. Use Server Parts for static content like blog posts.
  3. Use Client Parts for buttons, inputs, and search bars.
  4. Use Client Parts for anything that uses browser-only APIs.

I've found that most of my code can actually stay on the server. On a recent project for PostFaster, I moved 70% of my logic to Server Parts. The result was a much snappier time. You can see more about how I handle these setups on React. dev.

Why RSC Speed Benefits Change the Game

Why does this matter so much? It's all about the "Time to Interactive. " When a user visits your site, they want to see content fast. Traditional React apps make the user wait for the whole bundle to load. Then the app has to "hydrate. " This can cause a laggy feeling on mid-range phones.

Server parts fix this by doing the heavy work before the user even sees the page. I've seen apps reduce their first JS bundle by 40% or more. This isn't just a small tweak. It's a total shift in how we deliver web apps. Most devs see a 2x improvement in load times when they follow React Server Parts best practices, RSC vs client parts.

Key speed wins include:
Reduced Hydration: The browser has less work to do to make the page interactive.
Streaming: You can send parts of the page as they are ready.
No More Waterfalls: Fetch data for multiple parts at once on the server.
Smaller Bundles: Keep heavy libraries on the server side.

I once worked on a project where the search results page took 4 seconds to load. We were fetching data on the client. Each part waited for the past one to finish. By moving to Server Parts, we cut that time to under 1. 2 seconds. We fetched everything in parallel on the server. The user saw the results almost instantly.

React Server Parts best practices, RSC vs client parts: Setup Guide

Now, let's talk about how to actually build these. If you're using the Next. js App Router, every part is a Server Part by default. This is great because it forces you to think about the server first. To make a Client Part, you have to add the 'use client' directive at the very top.

I've learned that the "boundary" between these two is where things get interesting. You can't import a Server Part into a Client Part. But you can pass a Server Part as a "child" to a Client Part. This pattern is key for keeping your app fast. It lets you have an interactive wrapper around static content.

Follow these steps for a clean setup:

  1. Keep the 'use client' small: Only wrap the specific part that needs interactivity.
  2. Use Async/Await: Server parts can be async functions. This makes data fetching look like simple code.
  3. Pass data as props: Fetch your data in a Server Part and pass it down.
  4. Use Suspense for streaming: Wrap slow parts of your UI in a Suspense boundary.

Here is a quick code example of a Server Part:

// This is a Server Part by default
Async function UserProfile({ userId }) {
Const user = await db. user. findUnique({ id: userId }); // Direct DB access!

Return (
<div>
<h1>{user. name}</h1>
<ClientButton />
</div>
);
}
Enter fullscreen mode Exit fullscreen mode

And here is the Client Part it uses:

'use client'; // This tells React it's a Client Part

Export function ClientButton() {
Return <button onClick={() => console. log('Clicked!')}>Follow</button>;
}
Enter fullscreen mode Exit fullscreen mode

This simple split keeps your logic on the server. Only the button code goes to the user's browser. This is one of the core React Server Parts best practices, RSC vs client parts I use every day. You can find more patterns like this on Dev. to.

Avoiding Common Pitfalls and Mistakes

Even with time, it's easy to make mistakes with this new tech. One common error is putting 'use client' at the top of every file. People do this because they are used to the old way of working. But this makes your bundle huge again. You lose all the benefits of the server.

Another trap is trying to use hooks in Server Parts. You'll get an error if you try to use useState or useEffect. Remember, Server Parts don't have a "lifecycle" in the browser. They run once on the server and turn into HTML. If you need a hook, you must move that logic to a Client Part.

Watch out for these common issues:
Passing non-serializable data: You can't pass functions from a Server Part to a Client Part.
Context mismatch: React Context doesn't work in Server Parts. Use it only in client boundaries.
Large Client Parts: Don't put your whole page in a client part just because of one button.
Slow server fetches: If your server is slow, your whole page will be slow. Use streaming to fix this.

I've seen teams struggle with the "serializable" data rule. They try to pass a complex class or a function through a prop. It fails because the data has to be turned into JSON to cross the bridge. Stick to simple objects, strings, and numbers. If you need a function, define it inside the Client Part.

How Frameworks Handle These Parts Differently

While React provides the core tech, frameworks implement it in different ways. Next. js is the most famous example. It uses the App Router to make Server Parts the default. But other frameworks are catching up. Each has its own way of handling the "bridge" between server and client.

In Next. js, you get features like "Streaming" and "Server Actions" out of the box. This makes it very easy to follow React Server Parts best practices, RSC vs client parts. Other frameworks might require more manual setup. I always tell my friends to check the docs of their specific tool. The concepts stay the same, but the syntax can change.

Key differences to look for:
Routing: How the framework decides which parts to render.
Data Fetching: The specific APIs used to get data on the server.
Caching: How long the server keeps the rendered HTML.
Launch: Some frameworks need a specific server setup to work well.

I've spent a lot of time with Shopify Plus and KIBO Commerce. These platforms are starting to embrace these patterns too. It's an exciting time to be a dev. We finally have the tools to build "big" apps that feel "small" and fast. If you're looking for help with React or Next. js, reach out to me.

I've built everything from simple blogs to massive e-commerce sites for brands like Chanel. I know how to make these technologies work in the real world. Mastering React Server Parts best practices, RSC vs client parts is the best way to stay ahead. It's not just a trend; it's the future of the web. I'm always open to discussing interesting projects — let's connect.

[Contact me](http://i-ash.

Frequently Asked Questions

What are the essential React Server Components best practices, RSC vs client components for optimizing application performance?

The primary best practice is to use Server Components by default for data fetching and static content to keep the client-side bundle small. You should only "sprinkle" in Client Components at the leaf nodes of your component tree where immediate user interactivity or browser APIs are required.

How do I decide whether to use a React Server Component or a Client Component for a specific feature?

Choose Server Components when you need to access backend resources like databases or file systems directly without exposing sensitive logic to the browser. Opt for Client Components when your UI requires state management hooks like useState, lifecycle effects like useEffect, or event listeners for user input.

What is a common pitfall to avoid when implementing React Server Components best practices, RSC vs client components?

A frequent mistake is attempting to import a Server Component into a Client Component, which is not allowed because Server Components cannot run in the browser. To nest them correctly, you must pass the Server Component as a children prop to the Client Component, allowing the server to render it first.

Why do React Server Components offer better performance than traditional client-side rendering?

RSCs significantly reduce the amount of JavaScript sent to the client because the code used to fetch data and render the component stays on the server. This eliminates the "loading waterfall" effect and results in a much faster First Contentful Paint (FCP) for the end user.

Do I need a specific framework like Next.js to implement React Server Components?

While the RSC specification is part of the React library, it requires a sophisticated bundler and server-side integration to function correctly. Currently, frameworks like Next.js (via the App Router) provide the most stable and production-ready implementation of the RSC architecture.

Top comments (0)