Core Concepts Review, Practice & Interview Prep
Summary
Section titled “Summary”Important Concepts Covered
Section titled “Important Concepts Covered”Section 6 — Components
Section titled “Section 6 — Components”- Server Components run on the server, never hydrated — zero JS bundle impact
- Client Components (
"use client") handle interactivity and browser APIs - Hydration is React attaching to server-rendered HTML
dynamic()enables lazy loading for performance optimization- Composition pattern builds complex UIs from simple, focused components
Section 7 — Styling
Section titled “Section 7 — Styling”- CSS Modules provide scoped, conflict-free styles
- Tailwind CSS enables rapid development with utility classes
- Dark mode is implemented via
classtoggle and CSS variables - Mobile-first responsive design uses Tailwind’s breakpoint prefixes
Section 8 — Data Fetching
Section titled “Section 8 — Data Fetching”- Server-side fetching in async Server Components is the Next.js default
cache: "no-store"forces fresh data;next: { revalidate: N }enables ISR-style caching- Suspense + Streaming progressively loads page sections
- React Query handles complex client-side data management
Section 9 — Rendering Methods
Section titled “Section 9 — Rendering Methods”- SSG — fastest, built at compile time, best for static content
- SSR — always fresh, runs per request, best for personalized content
- ISR — static with automatic refresh, best for frequently updating content
- CSR — browser-rendered, best for real-time/interactive apps
Section 10 — API Routes
Section titled “Section 10 — API Routes”- Route Handlers (
route.ts) support all HTTP methods - Middleware runs before every request — ideal for auth
- Environment variables keep secrets server-side
- Zod validates and types API inputs automatically
Architecture Recap
Section titled “Architecture Recap”Next.js App├── Frontend (React Components)│ ├── Server Components → Run on server, zero JS, async data│ └── Client Components → Run in browser, interactive├── Styling│ ├── CSS Modules → Scoped, no conflicts│ └── Tailwind CSS → Utility-first, rapid development├── Data Layer│ ├── Server fetch → Direct DB/API access in components│ └── API Routes → /api/* for client fetching├── Rendering│ ├── SSG → Build-time HTML (CDN)│ ├── SSR → Per-request HTML│ ├── ISR → Periodic revalidation│ └── CSR → Browser rendering└── Backend (Route Handlers) ├── REST API → CRUD operations ├── Middleware → Auth, rate limiting └── DB integrations → MongoDB, MySQLKey Takeaways
Section titled “Key Takeaways”Performance Tips
Section titled “Performance Tips”- Default to Server Components — reduce client JavaScript bundle
- Use
dynamic()withssr: falsefor browser-only heavy libraries - Prefer SSG/ISR over SSR unless data must be per-request
- Use
Promise.all()for parallel data fetching (avoid waterfall) - Purge Tailwind correctly to keep CSS bundle minimal
- Use Suspense to progressively stream UI instead of loading states
Rendering Strategy Tips
Section titled “Rendering Strategy Tips”- Blog/docs/marketing → SSG (fastest + best SEO)
- Product listing → ISR (fresh enough + fast)
- User dashboard → SSR or CSR (personalized)
- Real-time features → CSR with polling or WebSockets
- Auth-protected pages → SSR with middleware
Component Best Practices
Section titled “Component Best Practices”- Keep components small and focused — one purpose each
- Lift state up when siblings need shared state
- Type all props with TypeScript interfaces
- Use composition instead of deeply nested props
- Name components clearly —
ProductCard, notCard2
Practice Exercises
Section titled “Practice Exercises”Beginner
Section titled “Beginner”- Create a
GreetingServer Component that accepts anameprop and displays a personalized message. - Build a
CounterClient Component usinguseState. - Write a CSS Module for a
Badgecomponent with 3 variants (success, warning, error). - Create a Tailwind-styled
Navbarthat is responsive on mobile. - Write an API route at
/api/pingthat returns{ status: "ok", timestamp: "..." }.
Intermediate
Section titled “Intermediate”- Build a
BlogListpage that fetches posts fromjsonplaceholder.typicode.comusing a Server Component. - Implement dark mode toggle using Tailwind’s
dark:prefix andlocalStorage. - Create a full CRUD API for a
Todoresource with in-memory storage. - Use
Suspenseto show a skeleton while a slow data component loads. - Implement a
Modalcomponent with Escape key close and click-outside close.
Advanced
Section titled “Advanced”- Build an ISR product page that revalidates every 5 minutes and supports on-demand revalidation.
- Implement JWT-based authentication with login/logout API routes and middleware protection.
- Create a streaming page where 3 sections load independently with different data sources.
- Build a file upload API with type and size validation, saving to disk.
- Implement a search API with MongoDB text search, pagination, and sorting.
- Create a theme system with CSS variables supporting light/dark/custom themes.
- Build a rate-limited API endpoint that allows 5 requests per minute per IP.
Mini Project Ideas
Section titled “Mini Project Ideas”1. Personal Blog Application
Section titled “1. Personal Blog Application”- Stack: Next.js + MDX + Tailwind + Vercel
- Features: SSG for articles, ISR for homepage, Dark mode, RSS feed
- API Routes: Newsletter signup, comment submission
2. Weather Application
Section titled “2. Weather Application”- Stack: Next.js + OpenWeather API + Tailwind
- Features: CSR with location detection, 5-day forecast, SSR for initial load
- Concepts: Client fetching, Suspense, skeleton loaders, Geolocation API
3. Admin Dashboard
Section titled “3. Admin Dashboard”- Stack: Next.js + MongoDB + Tailwind + JWT auth
- Features: Protected routes via middleware, Stats with charts, User management
- Concepts: SSR, API Routes, Middleware, CRUD operations, Data visualization
4. Authentication System
Section titled “4. Authentication System”- Stack: Next.js + NextAuth.js / custom JWT + MongoDB
- Features: Login/register, Google OAuth, Password reset, Profile management
- Concepts: JWT, HTTP-only cookies, Protected routes, Middleware, Email APIs
5. Product Management System (E-Commerce)
Section titled “5. Product Management System (E-Commerce)”- Stack: Next.js + MySQL + Stripe + Tailwind
- Features: ISR product pages, Cart with Zustand, Stripe payments, Admin panel
- Concepts: ISR, API routes, File uploads, Webhooks, Form validation
Interview Preparation
Section titled “Interview Preparation”Beginner Questions
Section titled “Beginner Questions”- What is Next.js and why use it over plain React?
- What is the App Router? How is it different from Pages Router?
- What is a Server Component?
- What does
"use client"do? - What is the difference between CSS Modules and global CSS?
- What is Tailwind CSS?
- What is data fetching?
- What is SSG?
- What is an API Route in Next.js?
- What is hydration?
Intermediate Questions
Section titled “Intermediate Questions”- Explain the difference between SSG, SSR, and ISR.
- When would you choose SSR over SSG?
- What is
next: { revalidate }and how does it work? - How do you protect routes in Next.js?
- What is
NextResponseand how do you use it? - What is the Composition Pattern in React?
- How does Tailwind’s
dark:prefix work? - What is the difference between
cache: "no-store"andcache: "force-cache"? - What is
dynamic()in Next.js? - How do you handle errors in Server Components?
Advanced Scenario-Based Questions
Section titled “Advanced Scenario-Based Questions”-
“Your blog is slow — how would you optimize it?” → Use SSG for articles, ISR for homepage, dynamic import for heavy editor, image optimization, prefetch.
-
“Your e-commerce site shows stale prices. What strategy would you use?” → ISR with
revalidate: 60(1 min) + on-demand revalidation triggered by inventory webhook. -
“You need to build a dashboard with user-specific data — what rendering method?” → SSR or CSR. SSR if SEO matters or initial render speed is critical. CSR if data is highly dynamic.
-
“How would you prevent an API key from being exposed in the browser?” → Keep in
.env.localwithoutNEXT_PUBLIC_prefix. Use API routes as proxy to call external APIs. -
“Your Server Component needs to render interactive content — how do you structure it?” → Server Component fetches data, passes it as props to a Client Component for interaction. Never make everything a Client Component.
-
“How would you implement authentication that persists across page refreshes?” → JWT stored in
httpOnlycookie, verified in middleware on every request. Never store JWT in localStorage. -
“You have 10 API calls on a page — how do you make them fast?” → Use
Promise.all()for parallel fetching. Use Suspense so each section streams independently. -
“What is a hydration error and how do you fix it?” → Server HTML doesn’t match client render. Fix: don’t use
Date.now()orMath.random()in Server Components without caution; usesuppressHydrationWarningsparingly.
End of Next.js Notes — Part 2
Sections 1–5 are covered in Part 1 (Foundations, File System, Routing, Layouts, Navigation).
Generated for PrepTechLab — Production-Ready Next.js Learning Resource