C.W.K.
Stream
Lesson 03 of 08 · published

Rendering Spectrum

~24 min · SSG, ISR, SSR, CSR

Level 0Curious
0 XP0/68 lessons0/11 achievements
0/120 XP to next level120 XP to go0% complete

Static, ISR, SSR, CSR — spectrum

웹 페이지는 "CDN 에서 그대로 서빙되는 fully static" 부터 "브라우저에서 JS 로 매번 그리는 fully dynamic" 사이 어딘가에 살아. Next.js 는 이 line 전체를 지원하고, route 별로 / fetch 별로 위치를 골라.

전략언제 골리는지
SSG (build time)request-time data 없음, fetch 가 cache 됨Docs, blog, marketing
ISR (revalidate)Static + revalidate 힌트Product page, news, pricing
SSR (per request)cookies(), headers(), searchParams 사용Auth'd page, dashboard, search
CSR (browser)Client Component 안에서 state 사용Live editor, collaborative UI

Next.js 가 mode 어떻게 detect 하는지

Mode 를 이름으로 고르는 게 아니라 — 호출하는 API 로 골라져. cookies()headers() 부르면 route 가 dynamic 으로 변하고, fetch 에 cache: 'force-cache' 붙이면 그 data 점은 static 이야. Build time 에 자동으로 detect 돼.

한 줄 짜기 전에 골라두는 이유

Spectrum 위 위치 잘못 고르면 Next.js app 이 비싸지거나 (전부 dynamic) stale 해져 (전부 static). Route 별로 결정해 — 뭐가 변하고, 얼마나 자주, freshness 비용은 누가 내?

Code

Default 가 static·tsx
// app/about/page.tsx
export default async function AboutPage() {
  const text = await fetch('https://api.example.com/about', {
    cache: 'force-cache',
  }).then(r => r.text());
  return <article>{text}</article>;
}
// Build time 에 한 번 render, 그 뒤로는 static HTML 로 서빙.
cookies() 만지면 dynamic·tsx
// app/dashboard/page.tsx
import { cookies } from 'next/headers';

export default async function Dashboard() {
  const session = (await cookies()).get('session'); // <- dynamic 으로 trigger
  const data = await fetchUserData(session?.value);
  return <DashboardView data={data} />;
}
// 매 request 마다 re-render — cookies() 가 request bound 라서.
Route segment 강제·tsx
// app/(marketing)/page.tsx
export const dynamic = 'force-static';

// app/(app)/page.tsx
export const dynamic = 'force-dynamic';

// Default: 'auto' — 코드 보고 detect.

External links

Exercise

작은 SaaS 의 rendering plan 글로 그려봐: marketing 사이트, 가격 매주 바뀌는 product catalog, 로그인된 dashboard. 각각 어떤 전략 + 어떤 Next.js feature 가 그 route 를 거기 놓는지.

Progress

Progress is local-only — sign in to sync across devices.
이 페이지에서 버그를 발견하셨거나 피드백이 있으세요?문제 신고

댓글 0

🔔 답글 알림 (로그인 필요)
로그인댓글을 남기려면 로그인해 주세요.

아직 댓글이 없어요. 첫 댓글을 남겨보세요.