next-pages-router

Implement Next.js Pages Router data fetching, API routes, and App Router migrations.

Updated Aug 27, 2026
One-click install
npx skills add https://github.com/zacharyr0th/next-starter --skill next-pages-router
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: next-pages-router
Source: https://github.com/zacharyr0th/next-starter/tree/main/.claude/skills/next/next-pages-router
Command: npx skills add https://github.com/zacharyr0th/next-starter --skill next-pages-router

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Expert guidance for Next.js Pages Router, including getStaticProps/getServerSideProps, dynamic routes, and legacy pages API.

Core Features & Use Cases

  • Data fetching (SSG/SSR), dynamic routes
  • Pages API routes and middleware patterns
  • Migration guidance to App Router when applicable

Quick Start

Request a migration plan from pages to app router for a given module.

Frequently Asked Questions about next-pages-router

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

FAQPage Schema
How do I implement getStaticProps and getServerSideProps in Next.js Pages Router?

getStaticProps generates static HTML at build time for fast performance; getServerSideProps renders on each request for dynamic data. Use getStaticProps for content that changes infrequently, getServerSideProps when data must be fresh on every request, and combine getStaticPaths for dynamic routes to pre-generate pages at build time.

What's the difference between SSG and SSR in Next.js pages?

Static Site Generation (SSG) pre-renders pages at build time via getStaticProps, delivering cached HTML instantly. Server-Side Rendering (SSR) via getServerSideProps renders on demand per request, ensuring current data but with latency trade-offs. Choose SSG for stable content, SSR for personalized or frequently updated data.

How do I create dynamic routes and API routes in the pages folder?

Dynamic routes use bracket syntax: pages/posts/[id].js matches /posts/123. API routes go in pages/api/—pages/api/users.js becomes POST /api/users. Use getStaticPaths with getStaticProps to pre-generate dynamic pages, or fetch dynamically with getServerSideProps. API routes handle request/response with standard Node.js patterns.

When should I migrate from Pages Router to App Router?

Migrate to App Router for better support of React Server Components, streaming, and layouts. Pages Router remains stable for existing projects. Migrate incrementally: App Router can coexist with pages/, or plan a full migration for cleaner organization and modern Next.js features like parallel routes and intercepting routes.

Can I use middleware with Next.js Pages Router?

Pages Router supports middleware via pages/_middleware.js (legacy) or middleware.js at root level in Next.js 12+. Middleware runs before route handlers for request transformation, authentication, redirects, and rewrites. For complex middleware logic, move to App Router, which has improved middleware integration.

How does Incremental Static Regeneration (ISR) work in Pages Router?

ISR lets getStaticProps revalidate static pages after deployment without rebuilding. Set revalidate: 60 to regenerate the page every 60 seconds on-demand. ISR balances static performance with fresh content, ideal for blogs, product pages, and frequently updated content that doesn't need on-request rendering.