Next.js App Router Builds and Fixes
Build and fix Next.js App Router features with explicit caching, secure mutations, streaming, and version-aware checks.
Before & after
Same prompt, same agent — the only difference is the skill.
Next.js 14+ uses App Router and Server Components by default, which changes how you fetch data. You can fetch directly in server components without needing separate API routes. You'd want to use the fetch API in your component and it will automatically cache the result. You could also use third-party data-fetching libraries if that fits your needs better. You might need to set up error boundaries and loading states so your users see something while data is loading. You could also use dynamic rendering if you need real-time data. It might help to know if you need real-time data, static data, or a mix of both. Have you already set up your project structure, and do you know what data source you're fetching from?
DATA FETCHING IN NEXT.JS 14+ SERVER COMPONENTS
PATTERN 1: STATIC DATA (default, fastest)
// app/posts/page.tsx (Server Component)
export default async function PostsPage() {
const posts = await fetch("https://api.example.com/posts")
.then(r => r.json());
return (
<div>
{posts.map(post => <PostCard key={post.id} post={post} />)}
</div>
);
}
Behavior: Builds at deploy time, cached forever
TTL: 3600s (1 hour default, overrideable)
Best for: Blog posts, docs, marketing pages
PATTERN 2: DYNAMIC DATA (real-time)
export const revalidate = 0;
export default async function DashboardPage() {
const data = await fetch("https://api.example.com/dashboard", {
cache: "no-store"
}).then(r => r.json());
return <Dashboard data={data} />;
}
Best for: Dashboards, user-specific data, live feeds
PATTERN 3: ISR (Incremental Static Regeneration)
export const revalidate = 60;
Behavior: Serves cached page, regenerates in background every 60s
Best for: Product listings, top news (semi-fresh data)
PATTERN 4: ERROR BOUNDARY + LOADING STATE
// app/posts/loading.tsx (auto-shown while fetching)
export default function Loading() {
return <SkeletonList count={5} />;
}
// app/posts/error.tsx (auto-shown on fetch failure)
"use client";
export default function Error({ error }) {
return <div>Error loading posts: {error.message}</div>;
}
METADATA FOR SEO
export const metadata = {
title: "Posts",
description: "Our latest posts",
openGraph: { image: "og-image-url" }
};
DEPLOYMENT TO VERCEL
1. Connect GitHub repo
2. Vercel auto-detects Next.js
3. Sets environment variables
4. Deploys on every push to main
COMMON MISTAKE: Fetching in useEffect on client components
// Wrong (defeats Server Component caching)
"use client";
useEffect(() => fetch("/api/posts"), []);
// Right (fetch in server component)
export default async function Posts() {
const posts = await fetch(...);
}
TIMING: ISR (60s) fast path average 20ms, dynamic (0s) path 400-800ms.About this skill
Your form saves, but the page still shows old data. A slow request blocks the whole route, or adding one interactive control turns the page into a client component. This skill builds and repairs Next.js App Router features by tracing server boundaries, cache behavior, and request flow before changing code.
What it does
- Chooses Server Components, Client Components, Server Actions, and Route Handlers for the actual interaction.
- Diagnoses stale data across the database, server cache, rendered route, and browser router state.
- Implements mutations with server-side validation, authorization, pending states, and targeted invalidation.
- Places Suspense, loading, error, and not-found boundaries where they affect the intended route segments.
- Adds static or dynamic metadata without leaking private data or unnecessarily blocking rendering.
- Checks framework versions, runtime requirements, and deployment constraints before recommending APIs or configuration.
What you get
A focused implementation or repair with file-specific code, explicit cache and security decisions, and checks matched to the failure. Larger requests include a bounded implementation sequence and an honest account of what was verified.
Best for
Developers building Next.js App Router applications, especially teams debugging stale UI, server/client boundary errors, slow routes, form mutations, or deployment-only failures.
SKILL.md preview
---
name: nextjs-app-router-builds-and-fixes
description: Build and repair Next.js App Router applications by tracing server/client boundaries, data freshness, mutation authorization, streaming, and deployment constraints against the installed framework version. Use when the user says "build this in Next.js", "my page still shows old data", "add a Server Action", "my entire page became client-side", "stream the slow part of this route", "fix this App Router error", "add metadata to this page", or "it works locally but fails on Vercel".
---
# Next.js App Router Builds and Fixes
… (sign up to view the full skill)More development skills
View all Development skills →Frontend Component UX and Accessibility Review
Severity-ranked fixes with code for UI components: states, keyboard, focus, ARIA, touch targets, contrast, and responsive breakage.
Three.js Click-to-Learn 3D Game Builder
Build click-to-learn 3D games in Three.js: TSL materials, reliable object picking, and an accessible quiz overlay fed by content data.
Angular Standalone Features and State Architecture
Build Angular standalone features with lazy routes, scoped state, safe RxJS flows, and targeted tests.
shadcn/ui Component Building and Theming
Build, theme, and debug shadcn/ui components the way the library is designed to work, with Tailwind v3 and v4 theming handled correctly.