nextjs
БесплатноБез исполняемых скриптовНе проверенAssists with building production-grade React applications using Next.js 16. Use when working with the App Router, Server Components, Server Actions, the proxy…
от TerminalSkills★ 221 звезда на GitHubОб этом скилле
Next.js
Overview
Next.js is a full-stack React framework. The App Router gives file-based routing, Server Components, Server Actions for mutations and streaming. Next.js 16 (current: 16.4) made Turbopack the default bundler, removed synchronous access to params, searchParams, cookies() and headers(), renamed middleware to proxy, and added opt-in Cache Components (use cache, Partial Prerendering). fetch requests are not cached by default (since 15). Check npm view next version and the upgrade guide at nextjs.org/docs/app/guides/upgrading/version-16 before assuming behavior from older projects.
Instructions
Setup
npx create-next-app@latest northwind-portal --yes # TypeScript, Tailwind, ESLint, App Router, Turbopack
cd northwind-portal
npm run dev # http://localhost:3000
next dev and next build use Turbopack by default (--turbopack is no longer needed). A custom webpack config makes next build fail unless you pass --webpack or move to turbopack options in next.config.ts. Upgrading an older app: npx @next/codemod@canary upgrade latest, then npx @next/codemod@canary next-async-request-api . for leftover synchronous params/cookies() access.
Routes and components
- Use
app/withpage.tsx,layout.tsx,loading.tsx(streaming),error.tsx(client component),not-found.tsx,route.tsfor HTTP handlers. - Components are Server Components by default; add
"use client"only for state, effects, event handlers or browser APIs. Keep the boundary low in the tree. paramsandsearchParamsare Promises. Await them, or type with the globalPageProps<'/orders/[id]'>helper (runnpx next typegento generate it):
// app/orders/[id]/page.tsx
export default async function Page({ params }: PageProps<'/orders/[id]'>) {
const { id } = await params
const order = await getOrder(id)
return <h1>Order {order.id}: {order.status}</h1>
}
cookies(), headers() and draftMode() are async too: const theme = (await cookies()).get('theme')?.value.
Data fetching and caching
Without Cache Components, fetch is uncached unless you pass { cache: 'force-cache' } or { next: { revalidate: 3600, tags: ['orders'] } }; route segment options export const revalidate = 3600 and dynamic still work. Query a database directly in a Server Component and co-locate the query with the component that needs it.
Cache Components is opt-in (cacheComponents: true plus partialPrefetching: true in next.config.ts). Data is then dynamic by default and you choose what to cache with the use cache directive; this replaces revalidate/dynamic/experimental_ppr route segment options and requires the Node.js runtime.
import { Suspense } from 'react'
import { cacheLife, cacheTag } from 'next/cache'
import { cookies } from 'next/headers'
async function getOrder(id: string) {
'use cache'
cacheLife('hours') // profiles: seconds, minutes, hours, days, weeks, max
cacheTag(`order-${id}`)
return db.order.findUnique({ where: { id } })
}
async function OrderDetails({ params }: { params: Promise<{ id: string }> }) {
const { id } = await params
const order = await getOrder(id)
return <h1>Order {order?.id}: {order?.status}</h1>
}
export default function Page({ params }: PageProps<'/orders/[id]'>) {
return (
<Suspense fallback={<p>Loading order...</p>}>
<OrderDetails params={params} />
</Suspense>
)
}
With Cache Components on, reading params, cookies(), headers() or uncached data outside a <Suspense> boundary fails next build ("uncached or runtime data during prerendering"). Fix it by moving the access into a component wrapped in <Suspense> (as above), caching it with use cache, or exporting instant = false to accept a blocking route. A use cache function cannot read cookies()/headers() itself: read them outside and pass values as arguments.
Mutations with Server Actions
// app/orders/actions.ts
'use server'
import { revalidateTag, updateTag } from 'next/cache'
import { redirect } from 'next/navigation'
import { z } from 'zod'
const Shipment = z.object({ orderId: z.string().min(1), carrier: z.enum(['dhl', 'ups', 'fedex']) })
export async function shipOrder(formData: FormData) {
const session = await getSession() // authorize inside every action
if (!session) throw new Error('Not signed in')
const input = Shipment.parse(Object.fromEntries(formData))
await db.order.update({ where: { id: input.orderId }, data: { status: 'shipped', carrier: input.carrier } })
updateTag(`order-${input.orderId}`) // Server Actions only: user sees their change immediately
revalidateTag('order-list', 'max') // stale-while-revalidate; second argument is required
redirect(`/orders/${input.orderId}`)
}
Use it as <form action={shipOrder}>. revalidateTag(tag, 'max') works
Установить nextjs в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
Вложенные файлы
FAQ
Что делает скилл nextjs?
Assists with building production-grade React applications using Next.js 16. Use when working with the App Router, Server Components, Server Actions, the proxy file (formerly middleware), Cache Components, or deploying to Vercel or self-hosted environments. Trigger words: nextjs, next.js, app router, server components, server actions, use cache, proxy.ts, react framework, ssr, isr.
Как установить скилл nextjs?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл nextjs запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
mcp-builder
Guide for creating high-quality MCP (Model Context Protocol) servers that enable LLMs to interact with external services through well-designed tools. Use when…
от Anthropicclaude-api
Reference for the Claude API / Anthropic SDK — model ids, pricing, params, streaming, tool use, MCP, agents, caching, token counting, model migration. TRIGGER…
от Anthropicalgorithmic-art
Creating algorithmic art using p5.js with seeded randomness and interactive parameter exploration. Use this when users request creating art using code…
от Anthropicmcp-integration
This skill should be used when the user asks to "add MCP server", "integrate MCP", "configure MCP in plugin", "use .mcp.json", "set up Model Context…
от Anthropic