Next.js
A React framework that lets you build full-stack web applications — handling both what the user sees (frontend) and what happens behind the scenes (backend) in one project.
What is Next.js?
React is a library for building user interfaces. It handles what things look like and how they respond to clicks, typing, and other interactions. But React alone doesn’t know how to serve pages to a browser, talk to a database, or make your site visible to search engines.1
Next.js is a framework built on top of React that adds everything React leaves out: routing (which URL shows which page), data fetching (getting information from servers or databases), rendering (deciding whether the server or the browser builds the HTML), and deployment optimisation.1
It’s built by Vercel, and it’s used in production by companies like Netflix, TikTok, and Twitch.2
In plain terms
If React is a set of LEGO bricks for building interfaces, Next.js is the instruction manual and baseplate — it gives you the structure, the conventions, and the plumbing so you can focus on what you’re actually building instead of figuring out how to wire everything together.
At a glance
How Next.js sits between you and the user (click to expand)
graph LR DEV[You write code] --> NX[Next.js] NX -->|Server Components| SR[Server renders HTML] NX -->|Client Components| CR[Browser renders interactive UI] NX -->|API Routes| API[Backend endpoints] SR --> USER[User sees the page] CR --> USER API --> DB[Database] style NX fill:#4a9ede,color:#fffKey: Next.js decides where each piece of your app runs — on the server (fast, secure, SEO-friendly) or in the browser (interactive, responsive to user actions). You control this per-component.
How does Next.js work?
1. File-based routing
In Next.js, your folder structure is your URL structure. Create a file, get a page — no configuration needed.1
app/
├── page.tsx → /
├── about/
│ └── page.tsx → /about
├── blog/
│ ├── page.tsx → /blog
│ └── [slug]/
│ └── page.tsx → /blog/my-post (dynamic)
└── api/
└── users/
└── route.ts → /api/users (API endpoint)
Think of it like...
A filing cabinet. The drawer is the domain, the folders are the URL segments, and each file labelled
page.tsxis what someone sees when they open that folder. You don’t need a map to find things — the structure is the map.
Concept to explore
See file-based-routing for how layouts, dynamic routes, and route groups work in the App Router.
2. Server Components and Client Components
This is the biggest idea in modern Next.js. Every component is either a Server Component or a Client Component, and the difference determines where it runs.3
| Server Component (default) | Client Component ('use client') | |
|---|---|---|
| Runs on | The server | The browser |
| Can do | Fetch data, read databases, use secrets | Handle clicks, track state, use browser APIs |
| Sends to browser | HTML (no JavaScript) | HTML + JavaScript |
| Good for | Content, data display, layouts | Forms, buttons, dropdowns, animations |
By default, everything in Next.js is a Server Component. You only
add 'use client' at the top of a file when that component needs
interactivity.3
Think of it like...
A newspaper. The articles, headlines, and photos are Server Components — they’re printed at the press (server) and delivered ready to read. The crossword puzzle is a Client Component — it needs the reader (browser) to interact with it. You wouldn’t send the entire printing press to someone’s house just so they can do the crossword.
The key rule
Default to Server Components. Only use Client Components when you need
useState,useEffect,onClick, or browser APIs likelocalStorage. This keeps your JavaScript bundle small and your pages fast.3
Concepts to explore
See server-components and client-components for deeper explanations with code examples.
3. Rendering strategies
Next.js gives you four ways to generate pages, and you can mix them in the same application:2
| Strategy | When HTML is built | Best for |
|---|---|---|
| Static (SSG) | At build time, once | Marketing pages, docs, blogs |
| Server-side (SSR) | On every request | Dashboards, personalised content |
| Incremental (ISR) | At build time, then refreshed in the background | Product pages, news sites |
| Client-side (CSR) | In the browser | Interactive widgets, admin tools |
A real-world mix (click to expand)
Consider an e-commerce site:
- Homepage → Static (SSG) for speed
- Product pages → ISR (rebuild every 60 seconds for stock)
- User dashboard → SSR (personalised per user)
- Shopping cart → CSR (interactive, browser-only state)
(These are illustrative examples — the same patterns apply to any domain.)
Concept to explore
See rendering-strategies for how each strategy works under the hood and when to choose which.
4. Server Actions
Server Actions let you write functions that run on the server but are called directly from your UI — no API route needed. They’re used for form submissions, database writes, and any mutation.1
// app/actions.ts
'use server'
export async function createPost(formData: FormData) {
const title = formData.get('title') as string
await db.post.create({ data: { title } })
revalidatePath('/blog')
}// app/blog/new/page.tsx
'use client'
import { createPost } from '@/app/actions'
export default function NewPost() {
return (
<form action={createPost}>
<input name="title" required />
<button type="submit">Publish</button>
</form>
)
}Think of it like...
A suggestion box. You write your suggestion (form data) and drop it in the box (call the Server Action). Someone in the back office (the server) reads it and takes action. You didn’t need to know where the back office is or how to get there — the box handled the delivery.
Concept to explore
See server-actions for validation, error handling, and optimistic updates.
Why do we use Next.js?
Five reasons
1. Full-stack in one project. Frontend, backend, and API routes live together. No separate server to build and deploy.1
2. SEO by default. Server-rendered HTML means search engines can read your content — unlike pure React, where the browser builds the page after loading JavaScript.2
3. Performance out of the box. Automatic code splitting, image optimisation, font optimisation, and route prefetching are built in.1
4. Flexibility. Mix static, server-rendered, and client-rendered pages in the same app. Choose the right strategy per page, not per project.
5. Ecosystem. TypeScript, Tailwind CSS, Prisma, and most React libraries work with zero or minimal configuration.
When do we use Next.js?
- When you’re building a multi-page web application (not just a single interactive widget)
- When SEO matters — blogs, marketing sites, e-commerce
- When you want frontend and backend in one codebase
- When you need different rendering strategies for different pages
- When you want a structured, convention-based project instead of wiring everything together manually
Rule of thumb
If your project has more than one page and needs to be found by search engines, Next.js is almost always the right choice. If you’re building a purely internal dashboard behind a login with no SEO needs, plain React may be simpler.
How can I think about Next.js?
The Swiss Army knife
React is a blade — sharp, versatile, essential. But a blade alone doesn’t help you open a bottle or tighten a screw. Next.js is the Swiss Army knife: it takes that blade and adds a corkscrew (routing), a screwdriver (data fetching), a can opener (API routes), and a case to hold it all together (deployment). You could carry each tool separately, but the integrated package is what makes you effective in the field.
The restaurant kitchen (revisited)
In the restaurant analogy, React is the chef’s knife — the core tool for preparing dishes (UI). Next.js is the entire kitchen setup: the layout of stations (routing), the order tickets (data fetching), the pass where dishes are plated (rendering), and the service window where waiters pick up orders (API routes). The knife does the cutting, but the kitchen makes the restaurant work.
Concepts to explore next
| Concept | What it covers | Status |
|---|---|---|
| server-components | Components that run on the server — no JS sent to browser | stub |
| client-components | Components that run in the browser — for interactivity | stub |
| file-based-routing | How folder structure becomes URL structure | stub |
| server-actions | Server functions called directly from UI | stub |
| rendering-strategies | SSG, SSR, ISR, CSR — when to use which | stub |
Some of these cards don't exist yet
They’ll be created as the knowledge system grows. A broken link is a placeholder for future learning, not an error.
Check your understanding
Test yourself (click to expand)
- Explain the difference between React and Next.js to someone who knows neither. What does Next.js add?
- Distinguish between a Server Component and a Client Component. When would you use each?
- Name the four rendering strategies and describe a situation where each would be the best choice.
- Interpret this scenario: a developer builds a blog entirely with Client Components and wonders why Google can’t find any of the posts. What went wrong?
- Connect Next.js to the client-server-model. How does Next.js blur the line between frontend and backend?
Where this concept fits
Position in the knowledge graph
graph TD SD[Software Development] --> CSM[Client-Server Model] CSM --> FE[Frontend] CSM --> BE[Backend] CSM --> API[APIs] FE --> NX[Next.js] FE --> HTML[HTML] FE --> CSS[CSS] FE --> JS[JavaScript] NX --> SC[Server Components] NX --> CC[Client Components] NX --> FBR[File-Based Routing] NX --> SA[Server Actions] NX --> RS[Rendering Strategies] style NX fill:#4a9ede,color:#fffRelated concepts:
- backend — Next.js API routes and Server Actions blur the line between frontend and backend
- apis — Next.js can both consume and expose APIs
- databases — Server Components and Server Actions can query databases directly
- client-server-model — Next.js is a concrete implementation of this model, where the framework manages both sides
Sources
Further reading
Resources
- Next.js Documentation — Official docs, well-written and kept up to date
- Learn Next.js — Free interactive course from the Next.js team, builds a full app step by step
- Complete Next.js Guide (Wojciechowski) — Thorough walkthrough of every major feature with code examples
- Server and Client Components (Next.js docs) — The official reference for the most important architectural decision in Next.js
- Next.js App Router: When Server Components Actually Make Sense — Practical decision guide for the Server/Client split
Footnotes
-
Vercel. (2026). Next.js Documentation. Vercel. ↩ ↩2 ↩3 ↩4 ↩5 ↩6
-
Wojciechowski, M. (2025). Complete Next.js 15 Guide. Wojciechowski.app. ↩ ↩2 ↩3
-
Next.js. (2026). Server and Client Components. Vercel. ↩ ↩2 ↩3