| name | nextjs-validator |
| description | Validate Next.js 16 configuration and detect/prevent deprecated patterns. Ensures proxy.ts usage, Turbopack, Cache Components, and App Router best practices. Use before any Next.js work or when auditing existing projects. |
| metadata | {"version":"1.0.0","tags":"nextjs, validation, frontend, react, turbopack"} |
Next.js Validator
Validates Next.js 16 configuration and prevents deprecated patterns. AI assistants often generate Next.js 14/15 patterns - this skill enforces Next.js 16.
When This Activates
- Setting up a new Next.js project
- Before any Next.js development work
- Auditing existing Next.js projects
- After AI generates Next.js code
- CI/CD pipeline validation
Quick Start
python3 scripts/validate.py --root .
python3 scripts/validate.py --root . --strict
What Gets Checked
1. Package Version
"next": "^16.0.0"
"next": "^15.0.0"
2. Proxy vs Middleware
GOOD - Next.js 16:
import { createProxy } from 'next/proxy';
export const proxy = createProxy();
BAD - Deprecated:
export function middleware() { }
3. App Router Structure
GOOD:
app/
├── layout.tsx # Root layout
├── page.tsx # Home page
├── (routes)/ # Route groups
│ ├── dashboard/
│ │ └── page.tsx
│ └── settings/
│ └── page.tsx
└── api/ # API routes (optional)
BAD - Pages Router (deprecated):
pages/
├── _app.tsx
├── index.tsx
└── api/
4. Cache Components & use cache
GOOD - Next.js 16:
'use cache';
export default async function Dashboard() {
const data = await fetch('/api/data');
return <DashboardView data={data} />;
}
5. Server Actions
GOOD:
'use server';
export async function createItem(formData: FormData) {
}
6. Turbopack Configuration
GOOD - Default in Next.js 16:
BAD - Disabling Turbopack:
experimental: {
turbo: false
}
7. Config File Format
GOOD - TypeScript config:
import type { NextConfig } from 'next';
const config: NextConfig = {
};
export default config;
BAD - JavaScript config:
module.exports = { }
Deprecated Patterns to Avoid
| Deprecated (v15-) | Replacement (v16+) |
|---|
middleware.ts | proxy.ts |
getServerSideProps | Server Components + use cache |
getStaticProps | Server Components + use cache |
getStaticPaths | generateStaticParams |
_app.tsx | app/layout.tsx |
_document.tsx | app/layout.tsx |
pages/ directory | app/ directory |
next/router | next/navigation |
useRouter() (pages) | useRouter() from next/navigation |
Next.js 16 Features to Use
Cache Components
'use cache';
export default async function CachedPage() {
const data = await fetchData();
return <View data={data} />;
}
Partial Pre-Rendering (PPR)
const config: NextConfig = {
experimental: {
ppr: true,
},
};
Next.js DevTools MCP
AI-assisted debugging with contextual insight:
Parallel Routes
app/
├── @modal/
│ └── login/
│ └── page.tsx
├── @sidebar/
│ └── default.tsx
└── layout.tsx
Intercepting Routes
app/
├── feed/
│ └── page.tsx
├── photo/
│ └── [id]/
│ └── page.tsx
└── @modal/
└── (.)photo/
└── [id]/
└── page.tsx
Validation Output
=== Next.js 16 Validation Report ===
Package Version: next@16.1.0 ✓
File Structure:
✓ Using app/ directory (App Router)
✗ Found pages/ directory - migrate to App Router
✓ Found proxy.ts
✗ Found middleware.ts - migrate to proxy.ts
Patterns:
✓ Using Server Components
✗ Found getServerSideProps in 2 files
✓ Using next/navigation
Config:
✓ next.config.ts (TypeScript)
✓ Turbopack enabled (default)
Summary: 2 issues found
- Migrate pages/ to app/ directory
- Replace middleware.ts with proxy.ts
Migration Guide
From middleware.ts to proxy.ts
Before (v15):
import { NextResponse } from 'next/server';
export function middleware(request) {
return NextResponse.next();
}
export const config = {
matcher: ['/dashboard/:path*'],
};
After (v16):
import { createProxy } from 'next/proxy';
export const proxy = createProxy({
async handle(request) {
return request;
},
matcher: ['/dashboard/:path*'],
});
From getServerSideProps to Server Components
Before:
export async function getServerSideProps() {
const data = await fetchData();
return { props: { data } };
}
export default function Dashboard({ data }) {
return <View data={data} />;
}
After:
export default async function Dashboard() {
const data = await fetchData();
return <View data={data} />;
}
CI/CD Integration
- name: Validate Next.js 16
run: |
python3 scripts/validate.py \
--root . \
--strict \
--ci
Integration
tailwind-validator - Validate Tailwind v4 config
biome-validator - Validate Biome 2.3+ config
clerk-validator - Validate Clerk auth setup