Install any skill in seconds. Free to start, no credit card required.
Get Started Free →Use this skill when working in a Next.js **App Router** codebase (Next.js 14+) and you need safe patterns for server vs client components, data fetching, routing, and deployment without introducing hydration bugs or accidental client bundles.
| Test case | Without → With | Effect | Δ tokens | Δ turns |
|---|---|---|---|---|
| case-01 | ✗→✓ | ▲ Improved | 76% | 0% |
| case-07 | ✗→✓ | ▲ Improved | 52% | 0% |
| case-15 | ✗→✓ | ▲ Improved | 9% | 0% |
| case-03 | ✓→✓ | = Same ✓ | 37% | 0% |
| case-04 | ✓→✓ | = Same ✓ | 26% | 0% |
Use this skill when working in a Next.js App Router codebase (Next.js 14+) and you need safe patterns for server vs client components, data fetching, routing, and deployment without introducing hydration bugs or accidental client bundles.
Rule: start server, add "use client" only when needed.
Use a Server Component when you:
Use a Client Component when you:
useState, useEffect, useRef)onClick, onChange)window, localStorage)Pattern:
page.tsx / layout.tsx typically serverPrefer server fetching:
fetch() (or a server SDK)cache, revalidate, and route segment config intentionallyClient fetching (when needed):
Use Route Handlers (app/api/.../route.ts) when:
Use Server Actions when:
Avoid:
Example: route handler boundary:
ts// app/api/health/route.ts import { NextResponse } from "next/server"; export async function GET() { return NextResponse.json({ ok: true }); }
Example: server action boundary:
ts// app/actions.ts "use server"; export async function updateProfile(_formData: FormData) { // validate input, call server service, redirect or return structured result }
Key ideas:
fetch() caching defaults can surprise you; be explicit when correctness matters.Rules of thumb:
revalidate periodically.Rules:
NEXT_PUBLIC_* is exposed to the browserPattern:
env.ts module for server-only validationRemember:
layout.tsx persists across routes in the segment; state can persist toopage.tsx re-renders per navigationCommon pitfall:
Use generateMetadata() for dynamic metadata, but keep it cheap:
Typical causes:
Date.now(), random IDs, or locale-dependent formatting on serverwindow/document in server componentsFix patterns:
useEffectsuppressHydrationWarning only as a last resortGood structure:
app/ routing + UIsrc/server/ services, DB, auth (server-only)src/shared/ types and utilities safe for bothEnforce boundaries:
Use Atlarix tools to stay tool-driven and avoid guessing Next.js internals:
grep/glob to find route segments, route handlers, server actions, and data fetching patterns; inspect layout.tsx boundaries.read_file + surgical edit tools for small changes, then run the project’s checks (often next lint, vitest, playwright).Useful checks:
"use client" too high in the tree?revalidate behavior.NODE_ENV, and validate output/standalone config if used."use client" to “make it work”revalidate/cache semantics intentionallyNEXT_PUBLIC_ only when needed)Other measured skills in the registry, with their headline benchmark lift.