Expert scaffolding for Next.js 14+ (App Router) projects. Enforces the use of Server Components, Server Actions, and strict TypeScript patterns.
CRITICAL: Before writing code, identify the project structure.
app/ directory exists.pages/ directory exists AND NO app/ directory.getServerSideProps / getStaticProps. Warn the user that this is legacy and suggest App Router if appropriate.When asked to create a page or component:
"use client" at the very top if and ONLY if you use:
useState, useEffectonClick)window, localStorage)useEffect for initial data fetching.// app/dashboard/page.tsx
export default async function DashboardPage() {
const data = await db.query('...'); // Direct DB access is allowed in Server Components!
return <ClientComponent data={data} />;
}
app/api/...) for simple form submissions.// actions.ts
'use server'
export async function updateUser(formData: FormData) {
const name = formData.get('name');
await db.user.update({ where: { name } });
revalidatePath('/profile');
}
import Link from 'next/link'.<Link href="/about">About</Link>import { redirect } from 'next/navigation'import { useRouter } from 'next/navigation' (NOT next/router)<title> tags to the head.page.tsx or layout.tsx.
import { Metadata } from 'next';
export const metadata: Metadata = {
title: 'Dashboard',
description: 'User statistics',
};
tailwind.config.ts is present, use utility classes.