Next.js โ React Framework Training
Last reviewed: 2026-05-29
Next.js is a React meta-framework created by Vercel that provides server-side rendering (SSR), static site generation (SSG), API routes, file-based routing, and full-stack capabilities out of the box. It's the recommended framework for production React applications.
Overview
Next.js extends React with:
- File-based routing โ Pages in app/ or pages/ automatically become routes
- App Router (Next.js 13+) โ New routing paradigm with React Server Components
- Rendering strategies โ SSR, SSG, ISR (Incremental Static Regeneration)
- API routes โ Build backend endpoints alongside frontend
- Middleware โ Edge-level request interception
- Image optimization โ Built-in <Image> component
- Font optimization โ next/font for self-hosted Google Fonts
- Turbopack โ Rust-based bundler (faster builds)
Training Content
App Router (Next.js 13+)
app/
โโโ layout.tsx # Root layout (wraps all pages)
โโโ page.tsx # Home page "/"
โโโ about/
โ โโโ page.tsx # /about
โโโ blog/
โ โโโ layout.tsx # Blog section layout
โ โโโ page.tsx # /blog (list)
โ โโโ [slug]/
โ โโโ page.tsx # /blog/:slug (dynamic route)
โโโ api/
โโโ hello/
โโโ route.ts # API endpoint /api/hello
Server vs Client Components
// Server Component (default in App Router)
// Can be async, direct DB access, no hooks
async function BlogList() {
const posts = await db.posts.findMany();
return <ul>{posts.map(p => <li>{p.title}</li>)}</ul>;
}
// Client Component โ add "use client" directive
// When you need interactivity, hooks, browser APIs
"use client";
function LikeButton() {
const [liked, setLiked] = useState(false);
return <button onClick={() => setLiked(!liked)}>โฅ</button>;
}
Data Fetching (App Router)
// Fetch at request time (dynamic)
async function Page() {
const data = await fetch('https://api.example.com/data');
return <div>{/* render data */}</div>;
}
- Static by default โ
fetch()defaults tocache: 'force-cache' - Dynamic โ
cache: 'no-store'ornext: { revalidate: 60 }for ISR - Server Components fetch directly โ no
useEffectneeded for data
Key Features
| Feature | Description |
|---|---|
| SSR | Render on each request (dynamic content) |
| SSG | Pre-build at build time (fast, cached) |
| ISR | Re-generate pages periodically (stale-while-revalidate) |
| Middleware | Edge functions for redirects, auth, i18n |
| Route Handlers | Full HTTP API endpoints in app/api/ |
| Server Actions | Form submissions without manual API routes |
Resources
- Next.js Documentation
- Next.js Learn โ Interactive tutorial
- Vercel Deploy โ Optimized hosting platform
- create-next-app