← スキル一覧に戻る

nextjs-server-components
by CoderMariusz
MonoPilot - Manufacturing and Purchase Order Management System
⭐ 1🍴 0📅 2026年1月20日
SKILL.md
name: nextjs-server-components description: When building Next.js App Router pages and deciding between Server and Client Components. version: 1.0.0 tokens: ~450 confidence: high sources:
- https://nextjs.org/docs/app/building-your-application/rendering/server-components
- https://react.dev/reference/rsc/server-components last_validated: 2025-01-10 next_review: 2025-01-24 tags: [nextjs, react, rsc, server-components, frontend]
When to Use
When building Next.js App Router pages and deciding between Server and Client Components.
Patterns
Default: Server Components
// app/page.tsx - Server Component by default
async function Page() {
const data = await db.query('SELECT * FROM posts');
return <PostList posts={data} />;
}
// ✅ Direct DB/API access
// ✅ Secrets safe (never sent to client)
// ✅ Zero client JS for this component
Client Component ("use client")
'use client'
// Only add when you NEED:
// - useState, useEffect, useContext
// - Event handlers (onClick, onChange)
// - Browser APIs (localStorage, window)
import { useState } from 'react';
export function Counter() {
const [count, setCount] = useState(0);
return <button onClick={() => setCount(c => c + 1)}>{count}</button>;
}
Composition Pattern
// Server Component (parent)
async function Dashboard() {
const user = await getUser();
return (
<div>
<UserInfo user={user} /> {/* Server */}
<InteractiveChart /> {/* Client */}
</div>
);
}
// Pass server data to client as props
<ClientComponent initialData={serverData} />
Data Fetching in Server Components
// ✅ Parallel fetching
async function Page() {
const [posts, user] = await Promise.all([
getPosts(),
getUser()
]);
return <Feed posts={posts} user={user} />;
}
Anti-Patterns
- Adding "use client" to every component (defeats RSC benefits)
- Importing server-only code in client components
- Passing functions as props from Server to Client
- Using useEffect for data that could be fetched on server
Verification Checklist
- "use client" only where actually needed
- No secrets in client components
- Server data passed as serializable props
- Parallel data fetching where possible
スコア
総合スコア
50/100
リポジトリの品質指標に基づく評価
✓SKILL.md
SKILL.mdファイルが含まれている
+20
○LICENSE
ライセンスが設定されている
0/10
○説明文
100文字以上の説明がある
0/10
○人気
GitHub Stars 100以上
0/15
○最近の活動
3ヶ月以内に更新がある
0/10
○フォーク
10回以上フォークされている
0/5
✓Issue管理
オープンIssueが50未満
+5
✓言語
プログラミング言語が設定されている
+5
○タグ
1つ以上のタグが設定されている
0/5
レビュー
💬
レビュー機能は近日公開予定です