secondsky/claude-skills / plugins/nextjs/skills/nextjs
nextjs
VerifiedNext.js 16 with App Router, Server Components, Server Actions, Cache Components. Use for React 19.2 apps, SSR, or encountering async params, proxy.ts migration, use cache errors.
| File | Kind | Size |
|---|---|---|
| SKILL.md | skill md | 14.5 KB |
| references/caching-apis.md | markdown | 8.4 KB |
| references/error-catalog.md | markdown | 8.9 KB |
| references/next-16-migration-guide.md | markdown | 11.7 KB |
| references/server-actions-patterns.md | markdown | 8.7 KB |
| references/top-errors.md | markdown | 11.8 KB |
| scripts/check-versions.shexecutable | script | 6.0 KB |
| templates/app-router-async-params.tsx | other | 8.0 KB |
| templates/async-params-page.tsx | other | 3.3 KB |
| templates/cache-component-use-cache.tsx | other | 9.5 KB |
| templates/package.json | manifest | 719 B |
| templates/parallel-routes-with-default.tsx | other | 10.7 KB |
| templates/proxy-migration.ts | script | 7.7 KB |
| templates/route-handler-api.ts | script | 10.8 KB |
| templates/server-action-form.tsx | other | 4.1 KB |
| templates/server-actions-form.tsx | other | 13.6 KB |
templates/async-params-page.tsx
View on GitHub/**
* Next.js 16 - Async Params Page Template
*
* BREAKING CHANGE: In Next.js 16, params and searchParams are now async.
* This template shows the correct pattern for Next.js 16+.
*/
import { Metadata } from 'next'
import { notFound } from 'next/navigation'
/**
* Page Component with Async Params
*
* IMPORTANT:
* - params is now Promise<{ id: string }>
* - searchParams is now Promise<{ query: string }>
* - Component must be async
*/
export default async function PostPage({
params,
searchParams
}: {
params: Promise<{ id: string }>
searchParams: Promise<{ query?: string }>
}) {
// 1. Await params (REQUIRED in Next.js 16)
const { id } = await params
// 2. Await searchParams (REQUIRED in Next.js 16)
const { query } = await searchParams
// 3. Fetch data (runs on server)
const post = await fetch(`https://api.example.com/posts/${id}`)
.then(r => r.json())
.catch(() => null)
// 4. Handle not found
if (!post) {
notFound()
}
// 5. Render
return (
<article>
<h1>{post.title}</h1>
<p>{post.content}</p>
{query && <p>Search query: {query}</p>}
</article>
)
}
/**
* Generate Metadata (also async in Next.js 16)
*/
export async function generateMetadata({
params
}: {
params: Promise<{ id: string }>
}): Promise<Metadata> {
// Await params
const { id } = await params
// Fetch data
const post = await fetch(`https://api.example.com/posts/${id}`)
.then(r => r.json())
.catch(() => null)
if (!post) {
return {
title: 'Post Not Found'
}
}
return {
title: post.title,
description: post.excerpt,
openGraph: {
title: post.title,
description: post.excerpt,
images: [post.coverImage]
}
}
}
/**
* Generate Static Params (for static generation)
*/
export async function generateStaticParams() {
// Fetch all post IDs
const posts = await fetch('https://api.example.com/posts')
.then(r => r.json())
// Return array of params
return posts.map((post: { id: string }) => ({
id: post.id
}))
}
/**
* Configure dynamic behavior
*/
export const dynamic = 'force-static' // or 'force-dynamic'
export const revalidate = 3600 // Revalidate every hour
/**
* Layout Component with Async Params
*
* File: app/posts/[id]/layout.tsx
*/
/*
export default async function PostLayout({
children,
params
}: {
children: React.ReactNode
params: Promise<{ id: string }>
}) {
const { id } = await params
return (
<div>
<header>Post {id}</header>
{children}
</div>
)
}
*/
/**
* Nested Dynamic Routes
*
* File: app/posts/[id]/comments/[commentId]/page.tsx
*/
/*
export default async function CommentPage({
params
}: {
params: Promise<{ id: string; commentId: string }>
}) {
const { id, commentId } = await params
return (
<div>
<p>Post ID: {id}</p>
<p>Comment ID: {commentId}</p>
</div>
)
}
*/
/**
* Migration Notes:
*
* Next.js 15 (OLD):
* - params: { id: string }
* - searchParams: { query: string }
* - cookies() - synchronous
* - headers() - synchronous
*
* Next.js 16 (NEW):
* - params: Promise<{ id: string }>
* - searchParams: Promise<{ query: string }>
* - await cookies() - async
* - await headers() - async
*
* Codemod:
* npx @next/codemod@canary upgrade latest
*/
Related skills
| Skill | Stars | Updated | Works with | Status | Install |
|---|---|---|---|---|---|
| brainstormingobra/superpowersYou MUST use this before any creative work - creating features, building components, adding functionality, modifying behavior, or planning anything new, in software or out of it (a talk, a business, a renovation). | Stars: 322k | Updated | Claude CodeCodex | Verified | Install |
| brand-guidelinesanthropics/skillsApplies Anthropic's official brand colors and typography to any sort of artifact that may benefit from having Anthropic's look-and-feel. Use it when brand colors or style guidelines, visual formatting, or company design standards apply. | Stars: 198k | Updated | Claude CodeCodex | Verified | Install |
| frontend-designanthropics/skillsGuidance for distinctive, intentional visual design when building new UI or reshaping an existing one. Helps with aesthetic direction, typography, and making choices that don't read as templated defaults. | Stars: 198k | Updated | Claude CodeCodex | Verified | Install |
| mcp-builderanthropics/skillsGuide for creating high-quality MCP (Model Context Protocol) servers that enable LLMs to interact with external services through well-designed tools. Use when building MCP servers to integrate external APIs or services, whether in Python (FastMCP) or Node/TypeScript (MCP SDK). | Stars: 198k | Updated | Claude CodeCodex | Verified | Install |