nextjs-optimization
БесплатноБез исполняемых скриптовНе проверенOptimize Next.js 15 applications for performance, Core Web Vitals, and production best practices using App Router patterns
от aiskillstore★ 509 звёзд на GitHubОб этом скилле
Next.js 15 Optimization Skill
Objective
Optimize Next.js applications to achieve:
- Perfect Core Web Vitals scores (LCP < 2.5s, FID < 100ms, CLS < 0.1)
- Fast page load times and optimal rendering strategies
- Efficient data fetching and caching
- Production-ready build configuration
- SEO and accessibility excellence
When to Use This Skill
Auto-invoke when:
- Project uses Next.js (detected by
nextin dependencies) - User mentions "optimize", "performance", "slow", or "Core Web Vitals"
- Before production deployment
- After adding new features or pages
- User requests Next.js-specific improvements
Prerequisites Check
Tools: Read, Grep
Verify Next.js version:
# Read package.json # Check for "next": "^15.0.0" or higherDetect App Router (Next.js 13+):
- Check for
app/directory - Check for
layout.tsx,page.tsxfiles
- Check for
Detect Pages Router (Legacy):
- Check for
pages/directory - Suggest migration to App Router
- Check for
Optimization Categories
1. Rendering Strategy Optimization
Goal: Choose optimal rendering for each page/component
Tools: Read, Grep, Edit
1.1 Server Components (Default in App Router)
When to use:
- Data fetching from APIs/databases
- Heavy computation
- Access to backend resources
Pattern:
// app/dashboard/page.tsx
export default async function DashboardPage() {
const data = await fetchData(); // Runs on server
return <Dashboard data={data} />;
}
Check for violations:
# Search for "use client" in components that don't need it
grep -r "use client" app/ | grep -v "onClick\|useState\|useEffect"
1.2 Client Components
When to use:
- Interactive UI (onClick, forms)
- Browser APIs (window, localStorage)
- React hooks (useState, useEffect)
Pattern:
// app/components/Counter.tsx
'use client';
export default function Counter() {
const [count, setCount] = useState(0);
return <button onClick={() => setCount(count + 1)}>{count}</button>;
}
Optimization: Keep client components small and leaf nodes
1.3 Static Generation (SSG)
When to use:
- Content that rarely changes
- Marketing pages, blogs, documentation
Pattern:
export const revalidate = 3600; // Revalidate every hour
export default async function BlogPost({ params }) {
const post = await getPost(params.slug);
return <Article post={post} />;
}
1.4 Dynamic Rendering with ISR
When to use:
- Content that changes periodically
- E-commerce products, user profiles
Pattern:
export const revalidate = 60; // Revalidate every minute
export async function generateStaticParams() {
const products = await getProducts();
return products.map((p) => ({ slug: p.slug }));
}
2. Image Optimization
Goal: Optimize images for performance and Core Web Vitals
Tools: Grep, Read, Edit
2.1 Use Next.js Image Component
Find unoptimized images:
grep -rn "<img " app/ src/
Replace with:
import Image from 'next/image';
<Image
src="/hero.jpg"
alt="Hero image"
width={1200}
height={600}
priority // For above-the-fold images
placeholder="blur" // Optional blur-up effect
/>
2.2 Configure Image Domains
Read next.config.js:
module.exports = {
images: {
remotePatterns: [
{
protocol: 'https',
hostname: 'example.com',
},
],
formats: ['image/avif', 'image/webp'], // Modern formats
},
};
2.3 Lazy Loading Strategy
- priority: Above-the-fold images (LCP candidates)
- loading="lazy": Below-the-fold images (default)
3. Font Optimization
Goal: Eliminate FOUT/FOIT and improve font loading
Tools: Read, Edit
3.1 Use next/font
Pattern:
// app/layout.tsx
import { Inter } from 'next/font/google';
const inter = Inter({
subsets: ['latin'],
display: 'swap', // Prevent FOIT
variable: '--font-inter',
});
export default function RootLayout({ children }) {
return (
<html lang="en" className={inter.variable}>
<body>{children}</body>
</html>
);
}
3.2 Self-Hosted Fonts
import localFont from 'next/font/local';
const customFont = localFont({
src: './fonts/CustomFont.woff2',
display: 'swap',
variable: '--font-custom',
});
4. Data Fetching Optimization
Goal: Minimize waterfalls and optimize cache
Tools: Read, Grep, Edit
4.1 Parallel Data Fetching
Anti-pattern (Sequential):
const user = await getUser();
const posts = await getPosts(user.id); // Waits for user
Optimized (Parallel):
const [user, posts] = await Promise.all([
getUser(),
getPosts(),
]);
4.2 Streaming with Suspense
Pattern:
import { Suspense } from 'react';
export default function Page() {
return (
<>
<Header />
<Suspense
Установить nextjs-optimization в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
Вложенные файлы
FAQ
Что делает скилл nextjs-optimization?
Optimize Next.js 15 applications for performance, Core Web Vitals, and production best practices using App Router patterns
Как установить скилл nextjs-optimization?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл nextjs-optimization запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
theme-factory
Toolkit for styling artifacts with a theme. These artifacts can be slides, docs, reportings, HTML landing pages, etc. There are 10 pre-set themes with…
от Anthropicaccess
Manage Discord channel access — approve pairings, edit allowlists, set DM/group policy. Use when the user asks to pair, approve someone, check who's allowed…
от Anthropicconfigure
Set up the Discord channel — save the bot token and review access policy. Use when the user pastes a Discord bot token, asks to configure Discord, asks "how…
от Anthropicaccess
Manage iMessage channel access — approve pairings, edit allowlists, set DM/group policy. Use when the user asks to pair, approve someone, check who's allowed…
от Anthropic