pages-router

Automate Next.js Pages Router setup and data fetching with getStaticProps and getServerSideProps.

Updated Apr 10, 2026
One-click install
npx skills add https://github.com/theslashdojo/dojo --skill pages-router-theslashdojo
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: pages-router
Source: https://github.com/theslashdojo/dojo/tree/main/nodes/nextjs/pages-router
Command: npx skills add https://github.com/theslashdojo/dojo --skill pages-router-theslashdojo

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes scripts (resource) components.

What problem does it solve?

Build Next.js apps that rely on the traditional Pages Router, providing clear guidance for creating routes, handling data fetching, and wiring _app.tsx and _document.tsx. This helps teams maintain consistency in projects that still use the pages directory.

Core Features & Use Cases

  • File-based routing using the pages/ directory, mapping each file to a route
  • Data fetching patterns via getStaticProps, getServerSideProps, and getStaticPaths
  • Global layout and HTML shell via _app.tsx and _document.tsx
  • Support for dynamic routes, nested folders, and API routes under pages/api
  • Suitable for maintaining legacy Next.js projects or gradual migration plan

Quick Start

Create a new page under pages/ and export getStaticProps or getServerSideProps as needed to fetch data.

Frequently Asked Questions about pages-router

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

FAQPage Schema
How do I use getStaticProps and getServerSideProps for Next.js Pages Router data fetching?

Next.js Pages Router uses getStaticProps for static generation and getServerSideProps for server-side rendering. Export these functions from your page files under the pages directory to fetch data at build time or request time.

What is the best way to structure dynamic routes in the Next.js pages directory?

Dynamic routes in the Next.js pages directory use file-based routing with bracket notation for dynamic segments. You can create nested folders and export getStaticPaths alongside getStaticProps to pre-render dynamic static pages.

How do I customize _app.tsx and _document.tsx for consistent Next.js Pages Router rendering?

Customize _app.tsx to persist layouts and global state across page transitions, and _document.tsx to modify the server-rendered HTML shell. These files ensure consistent rendering and global styling across all pages.

Can I use Next.js API routes with the Pages Router for backend endpoints?

Yes, Next.js Pages Router supports API routes by creating files under the pages/api directory. This maps each file to a serverless API endpoint, allowing backend functionality within the same project structure.

When should I choose Next.js Pages Router over the App Router?

Choose Next.js Pages Router for maintaining legacy Next.js projects or executing gradual migration plans. It provides established patterns for static pages, dynamic routes, and server-side rendering via exported data fetching functions.

Why does my Next.js Pages Router dynamic route return 404?

Next.js Pages Router dynamic routes require getStaticPaths to define which paths to pre-render. If getStaticPaths is missing or does not return the correct path parameters, the dynamic route returns a 404 error.