Skill#buildwithclaude
0
Routing conventions
'page.tsx' dosyası bir rota segmentini herkesin erişimine açık hale getirir:
yazan kuscubasiece·8 Eylül 2026
Kaynak: davepoon/claude-code-subagents-collection · MIT
'page.tsx' dosyası bir rota segmentini herkesin erişimine açık hale getirir:
Kaynak: davepoon/claude-code-subagents-collection · MIT
mkdir -p .claude/skills/routing-conventions && curl -sL https://www.antrophiclove.com/api/kaynak/routing-conventions/raw -o .claude/skills/routing-conventions/SKILL.mdHedef dosya: .claude/skills/routing-conventions/SKILL.md
The page.tsx file makes a route segment publicly accessible:
// app/dashboard/page.tsx
export default function DashboardPage() {
return <h1>Dashboard</h1>
}
Rules:
Shared UI that wraps page and nested layouts:
// app/dashboard/layout.tsx
export default function DashboardLayout({
children,
}: {
children: React.ReactNode
}) {
return (
<div>
<nav>Dashboard Nav</nav>
<main>{children}</main>
</div>
)
}
Rules:
children prop<html> and <body>Instant loading UI using React Suspense:
// app/dashboard/loading.tsx
export default function Loading() {
return (
<div className="flex items-center justify-center min-h-screen">
<div className="animate-spin rounded-full h-8 w-8 border-b-2 border-gray-900" />
</div>
)
}
Rules:
Error boundary for route segment:
// app/dashboard/error.tsx
'use client' // Must be a Client Component
export default function Error({
error,
reset,
}: {
error: Error & { digest?: string }
reset: () => void
}) {
return (
<div className="flex flex-col items-center justify-center min-h-screen">
<h2>Something went wrong!</h2>
<p>{error.message}</p>
<button onClick={() => reset()}>Try again</button>
</div>
)
}
Rules:
'use client')error and reset propsglobal-error.tsx)Error boundary for root layout:
// app/global-error.tsx
'use client'
export default function GlobalError({
error,
reset,
}: {
error: Error & { digest?: string }
reset: () => void
}) {
return (
<html>
<body>
<h2>Something went wrong!</h2>
<button onClick={() => reset()}>Try again</button>
</body>
</html>
)
}
UI for 404 responses:
// app/not-found.tsx
import Link from 'next/link'
export default function NotFound() {
return (
<div>
<h2>Not Found</h2>
<p>Could not find requested resource</p>
<Link href="/">Return Home</Link>
</div>
)
}
Triggering:
import { notFound } from 'next/navigation'
export default async function Page({ params }) {
const { id } = await params
const post = await getPost(id)
if (!post) {
notFound() // Triggers not-found.tsx
}
return <Post post={post} />
}
Like layout but re-renders on navigation:
// app/dashboard/template.tsx
export default function Template({ children }: { children: React.ReactNode }) {
return <div>{children}</div>
}
Use cases:
Fallback for parallel routes:
// app/@modal/default.tsx
export default function Default() {
return null
}
// app/dashboard/page.tsx
// Force dynamic rendering
export const dynamic = 'force-dynamic'
// Options: 'auto' | 'force-dynamic' | 'error' | 'force-static'
// Set revalidation time
export const revalidate = 3600 // seconds
// Set runtime
export const runtime = 'nodejs' // or 'edge'
// Maximum execution duration
export const maxDuration = 30 // seconds
// Prefer fetching certain data
export const fetchCache = 'auto'
// Options: 'auto' | 'default-cache' | 'only-cache' | 'force-cache' | 'force-no-store' | 'default-no-store' | 'only-no-store'
| Pattern | Example | Matches |
|---|---|---|
[folder] | [id] | /123 |
[...folder] | [...slug] | /a/b/c |
[[...folder]] | [[...slug]] | / or /a/b/c |
Organize without affecting URL:
app/
├── (marketing)/
│ ├── about/page.tsx # /about
│ └── contact/page.tsx # /contact
└── (shop)/
└── products/page.tsx # /products
Exclude from routing:
app/
├── _components/
│ └── button.tsx # Not a route
└── dashboard/
└── page.tsx # /dashboard
Named slots with @folder:
app/
├── @modal/
│ └── login/page.tsx
├── @sidebar/
│ └── page.tsx
├── layout.tsx
└── page.tsx
| Pattern | Intercepts |
|---|---|
(.)folder | Same level |
(..)folder | One level up |
(..)(..)folder | Two levels up |
(...)folder | From root |
Rendering order in a route segment:
layout.tsxtemplate.tsxerror.tsx (boundary)loading.tsx (boundary)not-found.tsx (boundary)page.tsx or nested layout.tsx