nextjs
Skill452 starsChanged 23 days agoApache-2.0View on GitHub
Next.js routing with typed routes, PageProps, LayoutProps helpers, and nuqs for URL state. Use for pages, layouts, navigation, and query parameters.
We split this skill into the rules it gives an agent
10 rules. 0 are common, 5 are distinctive, and 5 are very specific to this project.
0
Common
Most of the 32 edited versions we read keep these.
5
Distinctive
This author's own choices. Worth a look.
5
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 15
Use globally available PageProps, LayoutProps, RouteContext types - no imports needed
- Distinctive: line 16
RouteContext: Use for typing route handler context parameters with proper type inference
- Distinctive: line 17
PageProps: Use for page components with typed params and searchParams
- Distinctive: line 18
LayoutProps: Use for layout components with children and parallel route slots
- Distinctive: line 20
Always await Promise-based params and searchParams
- Very specific: line 26
Use Route type for props
- Very specific: line 27
Use as Route for non-literal strings (e.g., ('/blog' + slug) as Route)
- Very specific: line 31
NEVER use useParams from Next.js directly: - use typed alternatives from @/hooks/use-params
- Very specific: line 39
NEVER use useSearchParams from Next.js: - always use nuqs for URL query state
- Distinctive: line 40
Use appropriate parsers based on parameter data type
“Common” is measured: kept by at least 6 in 10 of the 32 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Next.js Routing & Navigation
Requirements
Route Props Helpers (Next.js 15.5+)
- Use globally available
PageProps,LayoutProps,RouteContexttypes - no imports needed - RouteContext: Use for typing route handler context parameters with proper type inference
- PageProps: Use for page components with typed params and searchParams
- LayoutProps: Use for layout components with children and parallel route slots
- Automatically includes typed params, searchParams, children, and parallel route slots
- Always await Promise-based params and searchParams
Typed Routes (Next.js 15.5+)
- TypeScript will catch invalid routes in
<Link>components at compile time - Automatically generates types based on your file structure
- Use
Routetype for props - Use
as Routefor non-literal strings (e.g.,('/blog' + slug) as Route)
Custom Param Hooks
- NEVER use useParams from Next.js directly - use typed alternatives from
@/hooks/use-params - Use unique param names (e.g.,
[userId]not[id]) for better type inference - useTParams
<Route>(): For specific app routes with exact typing - useLayoutParams(): For layout components, returns all params as optional
- useLayoutParams
<Route>(): For layout components with route prefix, exact route params required + prefix params optional
URL Query State
- NEVER use useSearchParams from Next.js - always use nuqs for URL query state
- Use appropriate parsers based on parameter data type
- Configure history mode and clearOnDefault
- Handle URL updates with void to prevent promise-related linting issues
Examples
<example>
// Page component with PageProps
export default async function Page(props: PageProps<'/products/[category]/[id]'>) {
const { category, id } = await props.params;
const searchParams = await props.searchParams;return (
<div>
<h1>Product: {id}</h1>
<p>Category: {category}</p>
</div>
);
}
</example>
<example>
// Layout with parallel routes
export default function DashboardLayout(props: LayoutProps<'/dashboard'>) {
return (
<div className="dashboard">
<aside>{props.sidebar}</aside> {/* Typed parallel route */}
<main>{props.children}</main>
<div>{props.analytics}</div> {/* Typed parallel route */}
</div>
);
}
</example><example>
// Route handler with RouteContext (recommended)
export async function GET(
request: Request,
ctx: RouteContext<'/api/posts/[slug]'>
) {
const { slug } = await ctx.params;
return Response.json({ slug });
}// Multiple parameters export async function DELETE( request: Request, ctx: RouteContext<'/api/users/[id]/posts/[postId]'> ) { const { id, postId } = await ctx.params; return Response.json({ userId: id, postId }); }
// Optional parameters
export async function PUT(
request: Request,
ctx: RouteContext<'/api/categories/[[...slug]]'>
) {
const { slug } = await ctx.params; // slug: string[] | undefined
return Response.json({ segments: slug });
}
</example>
<example>
// URL Query State with nuqs
export const useFilterState = () => {
return useQueryState(
'filter',
parseAsStringEnum(['all', 'active', 'completed'])
.withDefault('all')
.withOptions({ history: 'push', clearOnDefault: true })
);
};// Usage
const [filter, setFilter] = useFilterState();
void setFilter('active');
</example>
<example>
// Enable Typed Routes in next.config.ts
const nextConfig = {
typedRoutes: true, // Compile-time type safety for routes
};
export default nextConfig;// Usage in components import Link from 'next/link';
// ✅ Type-safe links
<Link href="/patients/123">View Patient</Link>
<Link href="/library/dx-tx?category=cardiology">Browse Library</Link>// ✅ Non-literal strings with Route type const slug = 'nextjs';
<Link href={('/blog/' + slug) as Route}>Blog Post</Link>
router.push(('/blog/' + slug) as Route);// ❌ TypeScript will catch invalid routes at compile time
<Link href="/invalid-route">Broken Link</Link> // ← Type error
</example><example>
// Custom Param Hooks Usage
import { useTParams, useLayoutParams } from '@/hooks/use-params';// ✅ For specific routes with exact typing const PatientPage = () => { const params = useTParams<'/patients/[patientId]'>(); params.patientId; // string - guaranteed to exist };
// ✅ For layouts - all params optional const RootLayout = ({ children }) => { const params = useLayoutParams(); params.patientId; // string | undefined params.complaintId; // string | undefined };
// ✅ For layouts with route prefix - exact + optional
const ComplaintLayout = ({ children }) => {
const params = useLayoutParams<'/complaints/[complaintId]'>();
params.complaintId; // string - required for exact match
params.someOtherParam; // string | undefined - from related routes
};
</example>
<example type="invalid">
// ❌ Don't use manual typing for route handlers
export async function GET(
request: Request,
{ params }: { params: Promise<{ slug: string }> }
) {
const { slug } = await params;
return Response.json({ slug });
}// ❌ Don't use manual typing for page props interface Props { params: Promise<{ slug: string }>; children: React.ReactNode; }
// ❌ Don't use raw useParams - use typed alternatives import { useParams } from 'next/navigation'; const params = useParams();
// ❌ Don't use useSearchParams import { useSearchParams } from 'next/navigation'; const searchParams = useSearchParams();
// ❌ Don't use string concatenation for routes
router.push(/patients/${id}); // Use typed routes instead
</example>
Other versions36 projects use a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 36
- openai/plugins★ 7.4ksame name
- leonvanzyl/agentic-coding-starter-kit★ 447same name
- kid-sid/claude-spellbook★ 190same name
- faqndo97/ai-skills★ 33same name
- nimadorostkar/Claude-Skills-collection★ 33same name
- PyModel/react-frontend-skills★ 23same name
- G1Joshi/Agent-Skills★ 15same name
- ulpi-io/browse★ 15same name
- wpank/ai★ 11same name
- belos-street/skill-kit★ 8same name
26 more not listed
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
Used alongsideProjects with it also use react, tailwind and 9 more.
Other files people use alongside this one.
Files found in the same public projects as a version of this one, more often than they turn up anywhere else. Each project counts once, large collections count for less, and this file's own repository is left out.
VercelSkillreact
React renderer for json-render that turns JSON specs into React components. Use when working with @json-render/react, building React UIs from JSON, creating component catalogs, or rendering AI-generated specs.
Also in 8 projects that use this
leonaaardobSkilltailwind
Complete Tailwind CSS documentation. Use when working with Tailwind CSS utility classes, responsive design, dark mode, animations, custom configurations, plugins, or styling questions. Covers all utility classes, modifiers, configuration options, and best practices.
Also in 4 projects that use this
Aver005Skilltanstack-query
Manage server state in React with TanStack Query v5. Covers useMutationState, simplified optimistic updates, throwOnError, network mode (offline/PWA), and infiniteQueryOptions.
Also in 3 projects that use this
hfzarslanSkillfastapi
FastAPI web framework skill for building REST APIs and web applications. Use when building FastAPI projects, creating APIs, adding features like database integration or authentication, structuring FastAPI applications, or when users ask to build/modify FastAPI code. Triggers include requests to create APIs, add endpoints, implement CRUD operations, set up authentication, integrate databases, add testing, or deploy FastAPI applications.
Also in 4 projects that use this
MicrosoftSkilltypescript
TypeScript best practices for this monorepo. Use this skill when: (1) writing new TypeScript code, (2) reviewing TypeScript code, (3) working with API responses, fetch calls, or JSON parsing, (4) adding or modifying types and interfaces.
Also in 5 projects that use this
klauswgSkillshadcn-ui
Expert guidance for integrating and building applications with shadcn/ui components, including component discovery, installation, customization, and best practices.
Also in 4 projects that use this
In this repository54 other files it gives its agents.
- .agents/AGENTS.mdAGENTS.md
- AGENTS.mdAGENTS.md
- .agents/skills/autoreview/AGENTS.mdAGENTS.md
- .agents/skills/autoreview/CLAUDE.mdCLAUDE.md
- CLAUDE.mdCLAUDE.md
- 4-ultraciteSkill
- agent-browser-issueSkill
- agent-native-reviewerSkill
- architecture-cleanupSkill
- autoclosureSkill
- autogoalSkill
- autoreviewSkill
- autoSkill
- avoid-feature-creepSkill
- better-auth-best-practicesSkill
- changeset-doc-syncSkill
- changeset-resolveSkill
- changesetSkill
- component-colocationSkill
- concave-paritySkill
- concaveSkill
- convex-release-auditSkill
- designSkill
- deslopSkill
- diagnosing-bugsSkill
- find-skillsSkill
- grill-with-visionSkill
- hard-cutSkill
- jotai-xSkill
- kitcnSkill
- linear-backlogSkill
- major-taskSkill
- next-dev-loopSkill
- orchestratorSkill
- package-release-auditSkill
- prototypeSkill
- react-querySkill
- research-wikiSkill
- resolve-pr-feedbackSkill
- resolving-merge-conflictsSkill
- scenariosSkill
- shadcn-paritySkill
- sync-convex-authSkill
- sync-visionSkill
- taskSkill
- tddSkill
- testingSkill
- toastSkill
- to-milestoneSkill
- to-prdSkill
- turborepoSkill
- video-transcriptsSkill
- visionSkill
- walkthroughSkill
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

