wsimmonds avatar

Nextjs Pathname Id Fetch

This is the pattern you reach for when building any page that fetches data based on a URL identifier, like product details, blog posts, or user profiles. It walks through creating dynamic routes with bracket notation (app/[id]/page.tsx), awaiting params in Next.js 15+, and fetching data in server components. The guide is opinionated about keeping things simple, staying server-side by default, and avoiding the any type. If you just need to grab an ID from the URL and load some data, this covers it cleanly. For catch-all routes or complex multi-parameter scenarios, you'll want the more comprehensive dynamic routes skill instead.

skills.sh installs
296
GitHub stars
110
last updated
Aug 21, 2026

Install

$ npx -y skills add wsimmonds/claude-nextjs-skills --skill nextjs-pathname-id-fetch --agent claude-code

Installs into .claude/skills of the current project.

Files

Next.js: Pathname ID Fetch Pattern

When This Pattern Applies

Use this pattern whenever a page needs to load data based on whatever identifier appears in the URL. Common scenarios include:

  • Detail pages for products, posts, or users (/products/{id}, /blog/{slug})
  • Admin dashboards that drill into a selected resource (/admin/orders/{orderId})
  • Documentation or knowledge bases with nested paths (/docs/getting-started/installation)

If the requirement says the data should change depending on the current URL path, the route segment must be dynamic (e.g., [id], [slug], [...slug]).

The Pattern

✅ Recommended implementation

1. Create a dynamic folder: app/[id]/page.tsx
2. Access the parameter: const { id } = await params;
3. Fetch data using that identifier
4. Render the requested information

❌ Pitfall

Using app/page.tsx for this scenario prevents access to per-path identifiers.

Complete Implementation Example

// app/[id]/page.tsx

Sponsors

Details

Repository
github.com/wsimmonds/claude-nextjs-skills
Categories
Frontend Development, Backend & APIs, Documentation
First seen
Jun 3, 2026

More from wsimmonds/claude-nextjs-skills

All 9
1wix avatarwix-cli-site-widgetwix/skillsUse when building interactive widgets, custom data displays, or configurable site components with settings panels. Triggers include widget, custom element, inte288skills.sh installs
2tech-leads-club avatarperf-astrotech-leads-club/agent-skillsAstro-specific performance optimizations for 95+ Lighthouse scores. Covers critical CSS inlining, compression, font loading, and LCP optimization. Use when opti286skills.sh installs
3patricio0312rev avatarreact-server-componentspatricio0312rev/skillsImplements React Server Components (RSC) patterns with Next.js App Router including data fetching, streaming, selective hydration, and server/client composition284skills.sh installs
4gentleman-programming avatartailwind-4gentleman-programming/gentleman-skillsTailwind CSS 4 patterns and best practices. Trigger: When styling with Tailwind - cn(), theme variables, no var() in className.279skills.sh installs
5thedivergentai avatargodot-ui-containersthedivergentai/gd-agentic-skillsExpert blueprint for responsive UI layouts using Container nodes (HBoxContainer, VBoxContainer, GridContainer, MarginContainer, ScrollContainer, HFlowContainer,279skills.sh installs
6microsoft avatarcomponent-fixturesmicrosoft/vscodeUse when creating or updating component fixtures for screenshot testing, or when designing UI components to be fixture-friendly. Covers fixture file structure, 277skills.sh installs