One of the biggest shifts in modern React and Next.js development is the introduction of Server Components and Client Components. These two types of components behave differently, are rendered differently, and serve different purposes.
In this guide, you’ll learn:
Let’s break it all down.
At the start of the crash course, you probably heard this statement:
“React components in Next.js are server components by default.”
That’s mostly true — but it can be confusing.
Let’s test it.
Open app/page.tsx and add:
console.log("What type of component am I?");
Now run your app and check the browser console.
Surprisingly… You’ll see the log in the browser console, not just the server terminal.
But this does not mean your component is running in the browser. Instead, Next.js mirrors server logs in the browser console for convenience.
✔ The component is still rendered on the server.
✔ The logs just appear in the browser.
✘ The component is NOT running on the client.
This is a display trick — not behavior change.
React Server Components (RSC) are components rendered exclusively on the server.
✔ Access server-only resources (files, databases, backend APIs).
✔ Keep sensitive data secure.
✔ Reduce JavaScript sent to the browser.
✔ Improve performance and time-to-render.
✘ Use browser APIs (window, document, etc.).
✘ Handle interactivity directly (click events, forms, routing).
✘ Use React hooks that rely on the browser (useState, useEffect).
Server Components output HTML, which is then sent to the browser.
They are great for:
Good question.
If your UI requires any kind of interactivity, such as:
…then you need a Client Component.
That brings us to the next part.
Client Components are rendered in the browser.
To create one in Next.js, you must add the directive:
"use client";
Example:
"use client";const Hello = () => {console.log("I am a client component");return <div>Hello from the client!</div>;};export default Hello;
Add this component inside a new components/ folder and render it in page.tsx.
You’ll now see two logs:
But here’s something strange…
You’ll also see the client component log in the server terminal.
Why?
(This is the part that confuses everyone!)
Client Components undergo two phases:
Server-side prerendering (SSR / SSG)
Client-side hydration
So a Client Component’s code runs:
✔ Once on the server (for pre-render) ✔ Once in the browser (for hydration)
This is normal and expected.
Hydration = taking existing server-rendered HTML and attaching:
If the server HTML doesn’t match what the client expects, you’ll get a hydration error.
Hydration allows:
This is a key feature of Next.js.
Here’s the simple rule:
✔ Only switch to Client Components when needed ✔ You’ll usually know you need a Client Component because:
Server Components = performance, security, minimal JavaScript Client Components = interactivity, state, dynamic behavior
This hybrid model is what makes Next.js powerful.
Next.js 16 includes built-in support for the new React Compiler, which:
useMemo or useCallbackTo enable it:
npm install babel-plugin-react-compiler@latest
next.config.ts:reactCompiler: true,
That’s it — cleaner code, better performance, fewer hooks to manage.
You now understand:
This foundation is essential before building anything serious with Next.js.
In the next lesson, you’ll apply this knowledge and begin using both component types together to build real features.