Back to list
kensleDev

nextjs-server-navigation

by kensleDev

0🍴 0📅 Jan 16, 2026

SKILL.md


name: nextjs-server-navigation

IMPORTANT: Keep description on ONE line for Claude Code compatibility

prettier-ignore

Next.js: Server Component Navigation

Quick Start

Server Components use DIFFERENT methods than Client Components!

MethodServer ComponentClient Component
Links<Link><Link>
Redirectredirect()❌ No
Router hook❌ NouseRouter()
// app/page.tsx - Server Component (NO 'use client'!)
import Link from 'next/link';

export default async function Page() {
  const data = await fetchData();  // Can fetch!

  return (
    <div>
      <h1>Welcome</h1>
      <Link href="/dashboard">Dashboard</Link>
      <Link href={`/products/${data.id}`}>View Product</Link>
    </div>
  );
}

Conditional Redirect

import { redirect } from 'next/navigation';

export default async function ProfilePage() {
  const session = await getSession();
  if (!session) redirect('/login');  // Server-side redirect
  return <div>Welcome</div>;
}

❌ WRONG - Adding 'use client' for Navigation

// ❌ WRONG
'use client';  // Don't add this just for links!
export default function Page() {
  return <Link href="/about">About</Link>;
}

✅ CORRECT - Keep as Server Component

// ✅ CORRECT
import Link from 'next/link';
export default async function Page() {
  return <Link href="/about">About</Link>;
}

Notes

  • No 'use client' needed: <Link> and redirect() work in Server Components
  • useRouter() is client-only: Only for Client Components
  • Last verified: 2025-01-11

Score

Total Score

40/100

Based on repository quality metrics

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

Reviews

💬

Reviews coming soon