
Software Architecture
A practical guide to choosing Server vs Client Components in Next.js, common hydration mismatch mistakes, and how to measure bundle size before and after.
In Next.js 13+, the distinction between Server Components and Client Components directly affects performance, scalability, and user experience. A web app with a smooth 150ms first render usually comes from picking the right component type.
In a booking management app, the dashboard displays 30+ realtime metrics. I used Server Components to fetch data from the backend API, then passed it down to Client Components for rendering. Result: 40% faster first render compared to using Client Components everywhere.
When I marked a chart component with 'use client', a hydration mismatch occurred because the server-rendered output differed from the client render. Result: broken UI visible to users.
When the server-rendered component differs from the client-rendered one:
// Server Component
function Chart() {
return <div>Data chart</div>;
}
// Client Component (misused)
'use client';
function Chart() {
useEffect(() => {
fetch('/api/data');
}, []);
return <div>Data chart</div>;
}Marking a non-interactive component with 'use client' pulls all React hooks and client-side logic into the bundle:
'use client';
function StaticContent() {
return <div>This is static content</div>;
}Too many unnecessary 'use client' markers make the codebase complex:
'use client';
function UserProfile({ user }) {
const [isEditing, setIsEditing] = useState(false);
return (
<div>
{isEditing ? <EditForm /> : <DisplayInfo />}
</div>
);
}Use it when the component needs user interaction (forms, buttons, animations) or hooks like useState/useEffect. Examples: login forms, dynamic data displays.
Make sure the server-rendered and client-rendered components match, and avoid unnecessary hooks in Server Components.
No. Server Components do not support hooks or user interaction. Use them for heavy data processing or static content rendering.
Use Webpack Bundle Analyzer to see how many KB each component takes, combined with Lighthouse for overall performance.
No automatic tool exists, but Next.js App Router automatically splits bundles: each page is its own bundle.
Choosing between Server and Client Components affects not only performance but also maintainability and scalability. By analyzing real examples and measuring bundle size, you can optimize your app effectively.
Keep exploring articles in this category.

Designing domain models, scoping aggregate boundaries and implementing repository interfaces in NestJS through a product module. Avoid stuffing logic into services.
Read article
Understand Server and Client Component boundaries in Next.js to reduce browser JavaScript without losing interactivity.
Read article