nextjs-production-debugger
Advanced debugging guide for Next.js App Router production issues including SSR/CSR bugs, hydration errors, runtime mismatches, performance, and caching.
Best use case
nextjs-production-debugger is best used when you need a repeatable AI agent workflow instead of a one-off prompt.
Advanced debugging guide for Next.js App Router production issues including SSR/CSR bugs, hydration errors, runtime mismatches, performance, and caching.
Teams using nextjs-production-debugger should expect a more consistent output, faster repeated execution, less prompt rewriting.
When to use this skill
- You want a reusable workflow that can be run more than once with consistent structure.
When not to use this skill
- You only need a quick one-off answer and do not need a reusable workflow.
- You cannot install or maintain the underlying files, dependencies, or repository context.
Installation
Claude Code / Cursor / Codex
Manual Installation
- Download SKILL.md from GitHub
- Place it in
.claude/skills/nextjs-production-debugger/SKILL.mdinside your project - Restart your AI agent — it will auto-discover the skill
How nextjs-production-debugger Compares
| Feature / Agent | nextjs-production-debugger | Standard Approach |
|---|---|---|
| Platform Support | Not specified | Limited / Varies |
| Context Awareness | High | Baseline |
| Installation Complexity | Unknown | N/A |
Frequently Asked Questions
What does this skill do?
Advanced debugging guide for Next.js App Router production issues including SSR/CSR bugs, hydration errors, runtime mismatches, performance, and caching.
Where can I find the source code?
You can find the source code on GitHub using the link provided at the top of the page.
SKILL.md Source
# Next.js Production Debugger (App Router)
Guía de supervivencia para debuggear aplicaciones Next.js App Router en producción.
## 1. Bugs SSR (Server) vs CSR (Client)
**Síntoma:** El bug ocurre solo en la carga inicial (F5) o solo al navegar (SPA transition).
| Escenario | Comportamiento | Diagnóstico |
| :------------- | :----------------------------------------------------------------------- | :-------------------------------------------------------------------------------------------- |
| **Bug en SSR** | La página carga rota con F5. Al navegar desde otra página funciona bien. | Revisa logs del TERMINAL del servidor. Deshabilita JS en el navegador para ver el HTML crudo. |
| **Bug en CSR** | La página carga bien con F5, pero falla al interactuar o navegar. | Revisa la consola del NAVEGADOR. Usa React DevTools. |
**Técnica de Aislamiento:**
1. **Deshabilitar JavaScript:** Si el contenido está mal sin JS, el problema es el Server rendering.
2. **Hard Refresh (Cmd+Shift+R):** Fuerza una nueva petición al servidor, ignorando el Router Cache del cliente.
## 2. Hydration Errors (The "Uncanny Valley")
**Error:** `Text content does not match server-rendered HTML` o `Hydration failed`.
**Causas Comunes:**
1. **Timestamps/Random:** Usar `Date.now()` o `Math.random()` directamente en el cuerpo del componente.
- _Solución:_ Mover a `useEffect` o usar una prop desde el servidor.
2. **HTML Inválido:** Poner un `<div>` dentro de un `<p>`, o `<ul>` dentro de `<p>`.
- _Check:_ Valida tu HTML. El navegador intenta corregirlo, creando discrepancias.
3. **Extensiones del Browser:** Plugins que inyectan HTML/CSS pueden romper la hidratación.
- _Prueba:_ Abre en modo Incógnito/Privado.
4. **`typeof window !== 'undefined'`:** Chequeos condicionales de renderizado basados en `window`.
- _Solución:_ Usa `useEffect` para montar componentes que dependen de `window`.
**Fix Rápido (Solo si es estético):**
`<div suppressHydrationWarning>{time}</div>`
## 3. Edge vs Node Runtime Mismatch
**Error:** `Module not found: Can't resolve 'fs'` o errores crípticos en Vercel/Middleware.
**Diagnóstico:**
- Revisa `export const runtime = 'edge'` en tus `page.tsx` o `route.ts`.
- **Problema:** El Edge Runtime es limitado (no tiene APIs de Node completas).
- **Librerías:** Algunas librerías npm asumen Node.js y fallan en Edge.
**Soluciones:**
1. Cambiar a `runtime = 'nodejs'` si necesitas compatibilidad total.
2. Si usas Middleware (siempre es Edge), asegúrate de usar APIs Web Standard (`fetch`, `Request`, `Response`) y no módulos de Node.
3. Usa `server-only` package para asegurar que código de servidor no se filtre al cliente.
## 4. Performance en App Router
**Síntoma:** "La página tarda mucho en cargar".
**Culpables Habituales:**
1. **Waterfalls (Fetch en Cascada):**
- _Mal:_ Componente A espera fetch -> Renderiza B -> B espera fetch.
- _Bien:_ `Promise.all([fetchA, fetchB])` en el padre, o preload patterns.
2. **Client Components Gigantes:**
- No hagas toda la página `use client`. Mueve la interactividad a las hojas (hojas del árbol de componentes).
3. **Blocking SSR:**
- Una petición de base de datos lenta en el `page.tsx` bloquea todo el HTML.
- _Solución:_ Envuelve la parte lenta en `<Suspense fallback={<Skeleton />}>` para Streaming SSR.
**Herramientas:**
- React DevTools Profiler.
- Pestaña "Network" en Chrome (mira el TTFB vs Content Download).
## 5. Caching Mal Configurado (El enemigo silencioso)
**Síntoma:** "Actualicé la DB pero la web sigue mostrando datos viejos".
**Capas de Cache en Next.js:**
1. **Request Memoization:** Dentro del mismo render pass. (Deduplica fetches iguales).
2. **Data Cache:** Persistente entre deploys/requests. (El `fetch` nativo lo hace).
- _Fix:_ `fetch(url, { cache: 'no-store' })` o `export const dynamic = 'force-dynamic'`.
3. **Full Route Cache:** Páginas estáticas generadas al build time.
- _Fix:_ `revalidatePath('/ruta')` en Server Actions.
4. **Router Cache (Client):** Cache en el navegador al navegar (dura 30s o 5min).
- _Fix:_ `router.refresh()` invalida este cache.
**Debug Flow:**
1. ¿Es dato viejo en el cliente? -> Refresca la página.
2. ¿Sigue viejo? -> Es Data Cache o Full Route Cache.
3. ¿Sigue viejo tras nuevo deploy? -> Revisa `revalidate` time o `no-store`.
---
**Comando útil:**
Usa `next build` localmente para ver qué páginas se generan como Estáticas (O) o Dinámicas (ƒ).Related Skills
nextjs-tanstack-form
TanStack Form v1 for Next.js 16 with Server Actions, Zod validation, and shadcn/ui integration. Use when building forms, validation, multi-step wizards, or dynamic field arrays.
nextjs-supabase-starter
Rules and best practices for building a Next.js starter app with Supabase (auth, profiles, RLS, declarative schemas, setup script). Use when working on Next.js + Supabase integration, authentication, migrations, or this starter app codebase.
nextjs-shadcn-builder
Build new Next.js applications or migrate existing frontends (React, Vue, Angular, vanilla JS, etc.) to Next.js + shadcn/ui with systematic analysis and conversion. Enforces shadcn design principles - CSS variables for theming, standard UI components, no hardcoded values, consistent typography/colors. Use for creating Next.js apps, migrating frontends, adopting shadcn/ui, or standardizing component libraries. Includes MCP integration for shadcn documentation and automated codebase analysis.
nextjs-senior-dev
Senior Next.js 15+/16 Engineer skill for App Router. Use when scaffolding production apps, enforcing RSC patterns, auditing codebases, or optimizing performance.
nextjs-frontend-guidelines
Next.js 15 frontend development guidelines for YGS (영영사) React 19/TypeScript application. Modern patterns including App Router, Server/Client Components, shadcn/ui components, Tailwind CSS 4, multi-method authentication (Firebase/Kakao/JWT), admin dashboard patterns, and Korean localization. Use when creating components, pages, API routes, fetching data, styling, or working with frontend code.
nextjs-code-reviewer
code reviews. Use when Codex needs this specialist perspective or review style.
nextjs-best-practices
Next.js App Router principles. Server Components, data fetching, routing patterns.
nextjs-app-router-patterns
Master Next.js 14+ App Router with Server Components, streaming, parallel routes, and advanced data fetching. Use when building Next.js applications, implementing SSR/SSG, or optimizing React Serve...
new-saas-production
Production-ready SaaS boilerplate generator. Creates complete project with public landing pages, client dashboard, admin panel, T-Bank payment integration, and v12-style design system. FastAPI + Jinja2 + PostgreSQL stack.
livekit-nextjs-frontend
Build and review production-grade web and mobile frontends using LiveKit with Next.js. Covers real-time video/audio/data communication, WebRTC connections, track management, and best practices for LiveKit React components.
js-reverse-automation-page-redirect-debugger
页面跳转 JS 代码定位通杀方案:在跳转前触发 debugger 以定位调用源。仅在确认跳转定位需求时启用。
chatgpt-apps-production-checklist
Turn ChatGPT Apps implementation work into a production-ready checklist with concrete tasks, tests, widget changes, and tool-result patterns mapped by priority (P0/P1/P2). Use when designing or hardening Apps SDK products for shipping; do not use for generic web-only apps, static code review, or non-ChatGPT integration planning.