Next.js โก Recently updatedUpdated on Jun 30, 2026 โ this content may still be evolving.
Next.js: Revision Sheet
Rendering (MEMORIZE)
| Pattern | When | App Router |
|---|---|---|
| SSG | Static, build time | fetch default cache |
| SSR | Per request, fresh | cache: 'no-store' |
| ISR | Static + regen | next: { revalidate: N } |
| CSR | Client fetch | 'use client' + useEffect |
Decision Quick Pick
- Blog/docs โ SSG
- Product catalog โ ISR
- User dashboard โ CSR/SSR + auth
- Personalized feed โ SSR
- Landing page โ SSG
App Router Structure
app/
layout.tsx # wraps all pages
page.tsx # route UI
loading.tsx # Suspense fallback
error.tsx # error boundary
[id]/page.tsx # dynamic route
api/.../route.ts
Server vs Client
- Server (default): async fetch, no hooks, smaller bundle
- Client:
'use client', useState, onClick
Key APIs
import Link from 'next/link';
import Image from 'next/image';
import { useRouter, useParams, useSearchParams } from 'next/navigation';
Pages Router (legacy)
getStaticPropsโ SSGgetServerSidePropsโ SSRgetStaticPathsโ dynamic SSG paths
Hydration
Server HTML + client JS attach. Mismatch if server โ client render.
Middleware
middleware.ts โ auth redirects, headers, geo routing.
Metadata
export const metadata = { title: '...', description: '...' };
Image
next/image โ optimized, lazy, requires width/height or fill.
Env Vars
NEXT_PUBLIC_*โ browser- Others โ server only
Quick Answers
| Question | Answer |
|---|---|
| App vs Pages Router? | App = RSC, layouts; new projects use App |
| Why ISR? | CDN speed + periodic updates without full rebuild |
| Link vs a? | Link client-side navigation, prefetch |
| Route groups? | (folder) organizes, not in URL |
| Server Actions? | Run server code from forms โ mutations |
Red Flags
- SSR everything (expensive)
- SSG for personalized pages (wrong data)
'use client'on entire app (defeats RSC)useEffectfetch what Server Component could do