Agent skill
handling-dynamic-routing
Logic for Next.js 15 Dynamic Routes. Use when building pages like `tours/[id]`.
Install this agent skill to your Project
npx add-skill https://github.com/majiayu000/claude-skill-registry/tree/main/skills/data/handling-dynamic-routing
SKILL.md
Dynamic Routing Patterns
When to use this skill
- Creating pages that depend on a parameter (slug, ID).
- Handling
paramsin Next.js 15 Server Components.
Workflow (Next.js 15)
- Define the folder:
app/tours/[id]/page.tsx. - Access
paramsas a Promise (required in v15). - Fetch data based on the resolved
id.
Implementation
interface TourPageProps {
params: Promise<{ id: string }>;
}
export default async function TourDetailsPage({ params }: TourPageProps) {
const { id } = await params; // Await the promise
const tour = await TourService.getById(id);
return (
<main>
<h1>{tour.title}</h1>
{/* ... */}
</main>
);
}
Instructions
- Metadata: Await
paramsingenerateMetadataas well. - Loading: Use
loading.tsxin the directory for automatic fallback UI.
Recommended Agent Skills
Expand your agent's capabilities with these related and highly-rated skills.
agent-ops-spec
Manage specification documents in .agent/specs/. Use when user provides requirements, acceptance criteria, or feature descriptions that need to be tracked and validated against implementation.
agent-ops-state
Maintain .agent state files. Use at session start, after meaningful steps, and before concluding: read/update constitution/memory/focus/issues/baseline consistently.
agent-ops-spec
Manage specification documents in .agent/specs/. Use when user provides requirements, acceptance criteria, or feature descriptions that need to be tracked and validated against implementation.
agent-ops-testing
Test strategy, execution, and coverage analysis. Use when designing tests, running test suites, or analyzing test results beyond baseline checks.
agent-ops-testing
Test strategy, execution, and coverage analysis. Use when designing tests, running test suites, or analyzing test results beyond baseline checks.
agent-ops-state
Maintain .agent state files. Use at session start, after meaningful steps, and before concluding: read/update constitution/memory/focus/issues/baseline consistently.
Didn't find tool you were looking for?