Claude-skill-registry handling-dynamic-routing
Logic for Next.js 15 Dynamic Routes. Use when building pages like `tours/[id]`.
install
source · Clone the upstream repo
git clone https://github.com/majiayu000/claude-skill-registry
Claude Code · Install into ~/.claude/skills/
T=$(mktemp -d) && git clone --depth=1 https://github.com/majiayu000/claude-skill-registry "$T" && mkdir -p ~/.claude/skills && cp -r "$T/skills/data/handling-dynamic-routing" ~/.claude/skills/majiayu000-claude-skill-registry-handling-dynamic-routing && rm -rf "$T"
manifest:
skills/data/handling-dynamic-routing/SKILL.mdsource content
Dynamic Routing Patterns
When to use this skill
- Creating pages that depend on a parameter (slug, ID).
- Handling
in Next.js 15 Server Components.params
Workflow (Next.js 15)
- Define the folder:
.app/tours/[id]/page.tsx - Access
as a Promise (required in v15).params - 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
inparams
as well.generateMetadata - Loading: Use
in the directory for automatic fallback UI.loading.tsx