Skip to content

Introduction to Next.js

Next.js is a React framework built by Vercel that adds powerful features on top of React — things React alone cannot do out of the box, like server-side rendering, file-based routing, automatic code splitting, and API routes.

Analogy: If React is the engine of a car, Next.js is the full car — body, wheels, dashboard, GPS, and all. You can drive with just the engine, but the complete car is far more practical.

React → A JavaScript library for building UI components
Next.js → A full-stack framework built on top of React

React by itself is a UI library. When developers started building real-world apps with React, they ran into recurring problems:

  • Pages weren’t indexed by search engines (bad SEO)
  • Initial page loads were slow (blank screen until JS loaded)
  • Setting up routing, API handling, and code splitting required lots of manual configuration
  • No standard way to fetch data before rendering

Vercel created Next.js in 2016 to solve all these problems with a single, opinionated framework.


ProblemWithout Next.jsWith Next.js
SEOPoor — content rendered client-sideExcellent — server renders HTML
Initial Load SpeedSlow — white screen until JS loadsFast — HTML arrives ready
RoutingManual setup with React RouterFile-based, zero config
API EndpointsSeparate backend requiredBuilt-in API routes
Code SplittingManual configurationAutomatic per page
Image OptimizationManualBuilt-in <Image> component
TypeScriptManual setupFirst-class support
DeploymentComplexOne-click on Vercel

  • Performance — Automatic static optimization, image optimization, lazy loading
  • SEO — Server-side and static rendering make pages crawlable
  • Developer Experience — Fast refresh, TypeScript, ESLint all built-in
  • Full-Stack — API routes let you write backend code in the same project
  • Flexibility — Mix SSR, SSG, ISR, and CSR per page
  • Scalability — Used by Fortune 500 companies in production

┌─────────────────────────────────────────────┐
│ NEXT.JS FEATURES │
├─────────────────┬───────────────────────────┤
│ App Router │ File-based routing system │
│ Server Comps │ React Server Components │
│ Data Fetching │ fetch() with caching │
│ API Routes │ Built-in backend endpoints │
│ Image Optim. │ <Image> component │
│ Font Optim. │ next/font │
│ Metadata API │ SEO metadata management │
│ Middleware │ Edge runtime functions │
│ Streaming │ Progressive rendering │
│ Turbopack │ Ultra-fast bundler │
└─────────────────┴───────────────────────────┘

✅ Use Next.js when:

  • Building a website that needs good SEO (blogs, marketing, e-commerce)
  • You need fast initial page loads
  • You want both frontend and backend in one project
  • Your team prefers React but needs more structure
  • Building a SaaS product, admin dashboard, or content platform

❌ Avoid Next.js when:

  • Building a highly interactive single-page app with no SEO needs (e.g., a real-time game or internal tool)
  • Your team is not familiar with React
  • You need a simple static site (use Astro or plain HTML)
  • You have strict self-hosting requirements with no Node.js support

CompanyUse Case
NetflixContent platform
TikTokWeb app
TwitchStreaming platform
GitHubDeveloper platform
NotionProductivity tool
HuluStreaming
AirbnbMarketplace
TargetE-commerce
OpenAIAI products (ChatGPT web)

YearVersionMajor Change
2016v1.0Initial release by Vercel
2018v7.0Dynamic routing
2020v9.5Incremental Static Regeneration (ISR)
2021v12Middleware, React 18 support
2022v13App Router (beta), Server Components
2023v13.4App Router stable
2024v14Partial Prerendering, Server Actions stable
2025v15Turbopack stable, improved caching

FeatureReactNext.js
TypeUI LibraryFull-stack Framework
RoutingManual (React Router)Built-in (file-based)
SSR❌✅
SSG❌✅
API Routes❌✅
SEOPoor by defaultExcellent
Code SplittingManualAutomatic
Image OptimizationManualBuilt-in
TypeScriptManual setupBuilt-in
Learning CurveLowerModerate
Bundle SizeSmallerLarger (more features)

SPA (React without Next.js)
──────────────────────────
Browser → Request Page
Browser ← Empty HTML (just <div id="root">)
Browser → Downloads JS bundle
Browser → Renders UI in browser
User sees content (slow first load)
Search bots see: empty page ❌
SSR (Next.js)
─────────────
Browser → Request Page
Server → Builds HTML with data
Browser ← Full HTML (instant content)
User sees content immediately ✅
Search bots see: full content ✅
Browser → Downloads JS (hydration)

SVG: Client vs Server Rendering diagram


SVG: Next.js Request Lifecycle diagram


Beginner:

  1. What is Next.js and how is it different from React?
  2. What does SSR stand for and why does it matter for SEO?
  3. Name three features of Next.js that React doesn’t have out of the box.

Intermediate: 4. What is hydration in Next.js? 5. Explain the difference between SSR, SSG, and ISR. 6. When would you choose Next.js over plain React?

Advanced: 7. How does Next.js App Router differ from Pages Router in its rendering model? 8. What is Partial Prerendering (PPR) introduced in Next.js 14? 9. Explain the trade-offs of CSR vs SSR in terms of Time to First Byte (TTFB) and Total Blocking Time (TBT).