Command Palette

Search for a command to run...

UnylyUnyly
Назад к скиллам

ssr-migration

БесплатноБез исполняемых скриптовНе проверен

Migrate client-side rendered (CSR) React/Vue applications to server-side rendering (SSR) or static site generation (SSG) using Next.js, Nuxt, or Astro. Use…

TerminalSkillsот TerminalSkills★ 221 звезда на GitHub

Об этом скилле

SSR Migration

Overview

This skill guides the migration of client-side rendered single-page applications to server-side rendering or static site generation. It covers the incremental migration strategy (not a rewrite), identifying which pages benefit from SSR vs SSG vs CSR, fixing hydration mismatches, adapting data fetching patterns, and configuring deployment for SSR workloads.

Instructions

1. Audit the current CSR application

Identify what needs to change before migrating:

# Check for SSR-incompatible patterns:
# 1. Direct window/document access at module level
grep -rn "window\." src/ --include="*.tsx" --include="*.ts" | grep -v "typeof window"

# 2. Browser-only libraries imported at top level
grep -rnE "from ['\"](chart\.js|swiper|mapbox-gl|leaflet)" src/

# 3. localStorage/sessionStorage usage outside useEffect
grep -rn "localStorage\|sessionStorage" src/ --include="*.tsx"

# 4. Dynamic imports that should stay client-only
grep -rn "React.lazy\|dynamic(" src/ --include="*.tsx"

Classify each page by rendering strategy:

  • SSG — content changes rarely, same for all users (marketing pages, blog posts, docs)
  • SSR — content changes frequently or is user-specific (dashboards, search results)
  • CSR — highly interactive, no SEO need (admin panels, internal tools)

2. Set up Next.js App Router alongside existing code

Migrate incrementally using the Next.js App Router (Next.js 16 is current). A Vite or CRA single-page app cannot be converted in place: create the Next.js project next to it, move one route at a time, and serve the rest through a rewrite until the old app is empty. Versions 15 and 16 changed three defaults this skill relies on: params/searchParams are Promises, cookies()/headers() are async, and fetch responses are not cached unless you ask (next: { revalidate } or cache: "force-cache").

// app/products/page.tsx — SSG with revalidation
export const revalidate = 3600; // Regenerate every hour

async function getProducts() {
  const res = await fetch("https://api.northwind-shop.com/products", {
    next: { revalidate: 3600 },
  });
  return res.json();
}

export default async function ProductsPage() {
  const products = await getProducts();
  return (
    <main>
      <h1>Products</h1>
      <ProductGrid products={products} />
    </main>
  );
}

// app/products/[id]/page.tsx — SSG with dynamic params
export async function generateStaticParams() {
  const products = await fetch("https://api.northwind-shop.com/products").then(r => r.json());
  return products.map((p: { id: string }) => ({ id: p.id }));
}

export default async function ProductPage({ params }: { params: Promise<{ id: string }> }) {
  const { id } = await params;
  const product = await fetch(`https://api.northwind-shop.com/products/${id}`, {
    next: { revalidate: 3600 },
  }).then(r => r.json());
  return <ProductDetail product={product} />;
}

3. Handle hydration mismatches

The most common migration bugs are hydration errors:

// BAD — different output on server vs client
function Greeting() {
  return <p>Current time: {new Date().toLocaleTimeString()}</p>;
}

// GOOD — defer client-only content
"use client";
import { useState, useEffect } from "react";

function Greeting() {
  const [time, setTime] = useState<string | null>(null);
  useEffect(() => {
    setTime(new Date().toLocaleTimeString());
  }, []);
  return <p>Current time: {time ?? "Loading..."}</p>;
}

4. Migrate data fetching patterns

// BEFORE (CSR): useEffect + useState
function Dashboard() {
  const [data, setData] = useState(null);
  useEffect(() => {
    fetch("/api/dashboard").then(r => r.json()).then(setData);
  }, []);
  if (!data) return <Spinner />;
  return <DashboardView data={data} />;
}

// AFTER (SSR): Server Component with async/await
import { cookies } from "next/headers";

async function Dashboard() {
  const cookieStore = await cookies();
  const data = await fetch("http://internal-api:8080/dashboard", {
    headers: { cookie: cookieStore.toString() },
    cache: "no-store", // per-user data must never be shared between requests
  }).then(r => r.json());
  return <DashboardView data={data} />;
}

5. Configure deployment for SSR

# Dockerfile for Next.js SSR
FROM node:22-alpine AS builder   # pin by digest in production, e.g. node:22-alpine@sha256:<digest>, so the base image is immutable
WORKDIR /app
COPY package*.json ./
RUN npm ci
COPY . .
RUN npm run build

FROM node:22-alpine AS runner
WORKDIR /app
ENV NODE_ENV=production
COPY --from=builder /app/.next/standalone ./
COPY --from=builder /app/.next/static ./.next/static
COPY --from=builder /app/public ./public
EXPOSE 3000
ENV HOSTNAME=0.0.0.0
CMD ["node", "server.js"]

The .next/standalone folder only exists when next.config.ts sets output: "standalone". Set HOSTNAME=0.0.0.0 so the container accepts outside connections, and run behind a reverse proxy (

Полный SKILL.md на GitHub

Установить ssr-migration в Claude Code и Claude Desktop

Зарегайся, чтобы установить скилл

Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.

  • Открой команду установки в одну строку
  • Сохраняй скиллы в синхронизируемую библиотеку
  • Уведомления, когда скиллы обновляются
Зарегаться бесплатноУ меня уже есть аккаунт

Разрешённые инструменты

Инструменты, которые скиллу разрешено вызывать.

Без ограничений — скилл может использовать любой инструмент.

Вложенные файлы

_scores.json

FAQ

Что делает скилл ssr-migration?

Migrate client-side rendered (CSR) React/Vue applications to server-side rendering (SSR) or static site generation (SSG) using Next.js, Nuxt, or Astro. Use when you need to improve SEO, reduce time-to-first-byte, fix blank page issues for crawlers, or improve Core Web Vitals. Covers incremental adoption, data fetching patterns, hydration debugging, and deployment configuration. Trigger words: SSR, SSG, server-side rendering, static generation, Next.js migration, SEO, hydration, TTFB, Core Web Vitals.

Как установить скилл ssr-migration?

Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.

Скилл ssr-migration запускает скрипты?

Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.

Похожие скиллы

Сравнить ssr-migration с