MSK Institute LogoMSK.Institute
HomeCourses
Book Free Demo➔Sign In
Free Demo➔
MSK Institute LogoMSK.Institute

Leading computer training academy in Shikohabad for software engineering, Python, web development, and digital literacy.

ISO 9001:2015 Certified Center
Follow & Connect
4.9

Programs & Admissions

  • All CoursesCatalog
  • Learning PathsRoadmaps
  • Student ProjectsShowcase
  • Live Classes & ScheduleLive
  • Upcoming Batches
  • Campuses & LocationsHub
  • Verify Certificates
  • Book Free Demo Class

Resources & Tools

  • Free Online Mock TestsAll Tests
  • NIELIT CCC Mock TestFree
  • Course & Career FinderQuiz
  • Study Material Hub
  • All MSK ToolsHub
  • Keyboard ShortcutsNew
  • TypeQuest Speed LabTyping
  • MSK Code PlaygroundCode
  • Interactive Tutorials
  • Quick Cheatsheets

Institute & Contact

  • About MSK Institute
  • Careers & InternshipsHiring
  • Publications & Blogs
  • Gali No. 3, Near Gyan Jyoti Public School,
    Adarsh Nagar, Shikohabad, Uttar Pradesh 283135
  • +91 83930 42166
  • mskshikohabad@gmail.com
  • Hours:Mon – Sat: 8:00 AM – 7:00 PM | Sun: 10:00 AM – 2:00 PM
  • 4.9 ★(38 Google Reviews)
© 2026 MSK Institute. All rights reserved.•Privacy Policy•Terms of Service•Disclaimer•Contact Us

Shikohabad's Leading Computer & Coding Academy

Home
Courses
Live
Material
Server Components vs Client Components ("use client" boundary)0%
Study Materials
Next.js 15Progress 0%
1.1Next.js 15 Overview & App Router vs Pages Router Architecture1.2Core File Conventions: page.tsx, layout.tsx, template.tsx & not-found.tsx1.3Dynamic Routes ([id]), Catch-All Routes ([...slug]) & Route Groups ((group))1.4Streaming UI with loading.tsx and Suspense Boundaries
2.1Server Components vs Client Components ("use client" boundary)2.2Data Fetching in Server Components & Async Server Logic2.3The Next.js 15 Caching System: Request Memoization & Data Cache2.4Static (SSG) vs Dynamic (SSR) Rendering & generateStaticParams
HomeTutorialsNext.js 15Server Components vs Client Components ("use client" boundary)
Data Fetching in Server Components & Async Server Logic

Server Components vs Client Components ("use client" boundary)

Beginner12 min read•Updated: 2026-11-18•By Er. Sumit Kumar (MSK Institute)
Study MaterialsCheatsheet

Understanding when to use React Server Components (RSC) and when to introduce the "use client" boundary is the single most important conceptual skill in modern Next.js engineering.


1. Comparing Server vs Client Components

FeatureServer Components (Default)Client Components ("use client")
Execution EnvironmentRuns only on the serverPre-rendered on server, hydrated in browser
Browser Bundle Impact0 KB (Dependencies stay on server)Added to browser JavaScript bundle
Direct Backend AccessFull access to databases, filesystems, env secretsNo direct access to databases/secrets
React Hooks❌ No useState, useEffect, useReducer✅ Full access to state, lifecycle, and custom hooks
Browser APIs & Events❌ No onClick, onChange, window, localStorage✅ Full access to DOM events and browser APIs

2. The "use client" Boundary

Adding "use client" at the very top of a file declares a boundary between server-only code and code that needs client interactivity. It does NOT mean the component runs only on the client! It will still be pre-rendered to HTML on the server during initial load, then hydrated in the browser with event listeners.

1// components/CounterButton.tsx
2'use client'; // This directive defines the client boundary!
3 
4import { useState } from 'react';
5 
6export default function CounterButton({ initialCount = 0 }: { initialCount?: number }) {
7 const [count, setCount] = useState(initialCount);
8 
9 return (
10 <button
11 onClick={() => setCount(count + 1)}
12 className="px-4 py-2 bg-blue-600 text-white rounded-lg hover:bg-blue-700"
13 >
14 Enrolled Students: {count}
15 </button>
16 );
17}

3. Composing Server and Client Components (The Golden Rule)

"Push client components down to the leaves of your component tree."

Instead of marking your entire page with 'use client', keep your layout and pages as Server Components (fetching data and securing secrets), and only import small client components where interactivity is strictly required:

1// app/courses/[slug]/page.tsx (Server Component - fetches data securely)
2import { getCourseFromDb } from '@/lib/db';
3import CounterButton from '@/components/CounterButton'; // Client Component imported as leaf!
4 
5export default async function CoursePage({ params }: { params: Promise<{ slug: string }> }) {
6 const { slug } = await params;
7 const course = await getCourseFromDb(slug); // Direct database query!
8 
9 return (
10 <div className="p-8">
11 <h1 className="text-3xl font-bold">{course.title}</h1>
12 <p>{course.description}</p>
13 
14 {/* Interactive client component receives server data as props */}
15 <CounterButton initialCount={course.enrolledCount} />
16 </div>
17 );
18}

Interactive Quiz• Knowledge Check

Multiple Choice Questions

Question 1
What does adding the 'use client' directive at the top of a file do?
Question 2
Why should developers "push client components down to the leaves of the component tree"?
Question 3
Which of the following is strictly prohibited inside a React Server Component?
Question 4
Can a Server Component be passed as a children prop into a Client Component?
Question 5
Why are secret API keys and database credentials safe inside a Server Component?

Next Lesson

Data Fetching in Server Components & Async Server Logic

Continue learning with hands-on practice, examples, and exercises in the upcoming topic.

Related Lessons

Previous LessonNext Lesson
Streaming UI with loading.tsx and Suspense BoundariesData Fetching in Server Components & Async Server Logic

Practice Quiz

Test your understanding of this lesson with 5 questions. Each question has one correct answer.

Mentor-Led Practical Training

Master Next.js 15 with Hands-On Projects

Practice in live mentor-led sessions with real projects, mock tests, and verifiable certification at MSK Institute.

View Full CourseBook Free Demo
PreviousNext
PreviousPrevNext