nextjs-routing

Guide client-side navigation in Next.js Pages Router with useRouter and Link.

3|Updated Dec 30, 2025
One-click install
npx skills add https://github.com/guicheffer/devorch-cli --skill nextjs-routing
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: nextjs-routing
Source: https://github.com/guicheffer/devorch-cli/tree/main/templates/skills/navigation/nextjs-routing
Command: npx skills add https://github.com/guicheffer/devorch-cli --skill nextjs-routing

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

This Skill provides comprehensive guidance and patterns for managing client-side navigation within Next.js applications using the Pages Router, ensuring smooth user experiences and efficient routing.

Core Features & Use Cases

  • useRouter Hook: Access routing information and methods within components.
  • Link Component: Declarative navigation with automatic prefetching.
  • Query Parameter Management: Accessing, preserving, and manipulating URL query parameters.
  • Programmatic Navigation: Using router.push() and router.replace() for dynamic routing.
  • Use Case: Seamlessly guide users through a multi-step checkout process, preserving necessary query parameters like cartId and locale while updating the current step.

Quick Start

Use the nextjs-routing skill to implement client-side navigation for a web application.

Frequently Asked Questions about nextjs-routing

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I implement client-side navigation in Next.js using the Pages Router?

Client-side navigation in Next.js is implemented using the `Link` component for declarative routing and the `useRouter` hook for programmatic routing. This ensures smooth transitions and efficient page updates without full reloads.

How do I preserve URL query parameters during programmatic navigation in Next.js?

To preserve URL query parameters during Next.js navigation, use the `useRouter` hook to access current queries and pass them into `router.push()` or `router.replace()`. This maintains state like `cartId` or `locale` across transitions.

What is the difference between declarative and programmatic routing in Next.js?

Declarative routing in Next.js uses the `Link` component for automatic prefetching on user interaction, while programmatic routing uses `router.push()` and `router.replace()` for dynamic, conditional navigation triggered by application logic.

Can I use the Next.js useRouter hook for conditional navigation?

Yes, the `useRouter` hook supports conditional navigation by executing `router.push()` or `router.replace()` based on dynamic application state, allowing seamless multi-step processes like guided checkouts.

When should I use router.push instead of router.replace for Next.js navigation?

Use `router.push` to add a new entry to the browser history stack, allowing users to use the back button, and `router.replace` to update the current URL without leaving history traces, ideal for URL state updates.