Files
2nd/10_Wiki/Topics/Architecture/Web-Rendering-Strategies-CSR-vs-SSR.md
T
koriweb d8a80f6272 chore(wiki): dangling 링크 canonical 정규화 (768파일/1200건)
이름만 다른(표기 변형) [[위키링크]]를 대상 문서의 canonical 제목으로 치환해
끊겼던 1,200개 링크를 연결. 제목/파일명 정규화 일치만 적용하고 별칭 매칭은
과병합 위험으로 제외(애매성 가드). 원본은 _link_reconcile_backup/ 에 백업.
도구: Datacollect/scripts/link_reconcile_apply.mjs

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-08 12:24:15 +09:00

6.0 KiB

id, title, category, status, canonical_id, aliases, duplicate_of, source_trust_level, confidence_score, verification_status, tags, raw_sources, last_reinforced, github_commit, tech_stack
id title category status canonical_id aliases duplicate_of source_trust_level confidence_score verification_status tags raw_sources last_reinforced github_commit tech_stack
wiki-2026-0508-web-rendering-strategies-csr-vs- Web Rendering Strategies — CSR vs SSR 10_Wiki/Topics verified self
CSR vs SSR
SSG
ISR
Rendering Strategies
Hybrid Rendering
none A 0.9 applied
rendering
ssr
csr
ssg
isr
frontend
performance
2026-05-10 pending
language framework
typescript nextjs

Web Rendering Strategies — CSR vs SSR

매 한 줄

"매 어디서 render 매 (server/build/client/edge), 매 언제 (request/build/runtime), 매 무엇 (static/dynamic) — 매 이 3 축 의 매 trade-off". 매 2026 매 hybrid (RSC + Streaming SSR + ISR + Edge) 매 default — Next.js / Nuxt / Remix / SvelteKit / Astro 매 모두 mix.

매 핵심

매 5 가지 strategy

  • CSR (Client-Side Rendering): empty HTML + JS bundle → browser 매 render. SPA classic.
  • SSR (Server-Side Rendering): per-request HTML on server.
  • SSG (Static Site Generation): build-time HTML.
  • ISR (Incremental Static Regeneration): SSG + on-demand or time-based revalidate.
  • RSC (React Server Components, 2023~): server-only component, zero JS ship for that part.

매 핵심 metric

  • TTFB: server response time.
  • FCP / LCP: 매 visible content speed.
  • TTI: 매 interactive — hydration cost.
  • INP: 매 interaction latency (FID 의 후속, Core Web Vitals 2024+).
  • JS bundle: 매 작을 수록 hydration fast.

매 응용

  1. Marketing site → SSG / ISR (Astro, Next).
  2. E-commerce → ISR + dynamic SSR for cart.
  3. Dashboard / admin → CSR or SSR with auth.
  4. Blog → SSG + ISR.
  5. Real-time chat → CSR + SSE/WebSocket.
  6. News site → ISR (revalidate every 60s).

💻 패턴

Next.js App Router (RSC + streaming)

// app/products/[id]/page.tsx — RSC, fetched on server, no JS shipped
export default async function ProductPage({ params }: { params: { id: string } }) {
  const product = await db.product.findUnique({ where: { id: params.id } });
  return (
    <article>
      <h1>{product.name}</h1>
      <Suspense fallback={<Skeleton />}>
        <Reviews productId={params.id} />
      </Suspense>
    </article>
  );
}

ISR with revalidate

// Next.js — 매 60s 마다 background regenerate
export const revalidate = 60;
export default async function Posts() {
  const posts = await fetch("https://api.example.com/posts").then((r) => r.json());
  return <ul>{posts.map((p) => <li key={p.id}>{p.title}</li>)}</ul>;
}

SSG with generateStaticParams

export async function generateStaticParams() {
  const slugs = await getAllSlugs();
  return slugs.map((slug) => ({ slug }));
}

CSR via dynamic + ssr:false

"use client";
import dynamic from "next/dynamic";
const Chart = dynamic(() => import("./HeavyChart"), { ssr: false });
export default function Page() { return <Chart />; }

Streaming SSR (Suspense)

// app/dashboard/page.tsx
export default function Dashboard() {
  return (
    <>
      <Header />
      <Suspense fallback={<Skel />}><SlowWidget /></Suspense>
      <Suspense fallback={<Skel />}><AnotherSlow /></Suspense>
    </>
  );
}
// 매 shell 먼저 flush, 매 widget ready 시 stream

Edge runtime (Vercel / Cloudflare Workers)

// Next.js — Edge 매 cold start 매 0 에 가까움
export const runtime = "edge";
export async function GET(req: Request) {
  const country = req.headers.get("x-vercel-ip-country") ?? "US";
  return new Response(`Hello from ${country}`);
}

Astro islands

---
// 매 default static, 매 island 만 hydrate
import Counter from "../components/Counter.tsx";
const posts = await fetch("...").then((r) => r.json());
---
<html>
  <body>
    {posts.map((p) => <article><h2>{p.title}</h2></article>)}
    <Counter client:visible />  <!-- viewport entry 시 hydrate -->
  </body>
</html>

On-demand revalidation

// Next.js — webhook 받으면 매 즉시 invalidate
import { revalidateTag, revalidatePath } from "next/cache";
export async function POST(req: Request) {
  const { tag } = await req.json();
  revalidateTag(tag);
  return Response.json({ ok: true });
}

매 결정 기준

상황 Approach
Static marketing SSG / Astro
Blog with comments SSG + CSR comments
News feed (changes hourly) ISR (revalidate=3600)
Product page + cart RSC + Client island for cart
Real-time dashboard CSR + WebSocket
Geo-personalized Edge SSR
Authenticated app SSR with auth + RSC

기본값: Next.js App Router (RSC default) + Suspense streaming + ISR for content. 매 client component 매 조심히.

🔗 Graph

🤖 LLM 활용

언제: Rendering strategy 결정, Next.js / Nuxt / Astro setup, Core Web Vitals tuning. 언제 X: Pure native app, internal CLI, embedded device UI.

안티패턴

  • CSR for SEO-critical content: 매 crawler 매 problem.
  • SSR everywhere without caching: 매 server CPU 폭발 — ISR / cache 도입.
  • Hydration mismatch: server HTML ≠ client render — 매 console error + flicker.
  • Massive client bundle: 매 hydration TTI 늦어짐 — RSC / island 활용.
  • No streaming: 매 slow API 매 entire page block — Suspense.
  • Misuse of "use client": 매 RSC tree 의 매 leaf 만 client.

🧪 검증 / 중복

  • Verified (Next.js 15 docs, Vercel team blog, web.dev rendering guide 2025).
  • 신뢰도 A.

🕓 Changelog

날짜 변경
2026-05-08 Phase 1
2026-05-10 Manual cleanup — RSC, streaming, ISR, edge runtime patterns