Skip to content

Repository files navigation

next-list

npmCILicense: MIT

artisan route:list for Next.js. Point it at an App Router project and it prints every page, route handler and special file — with the URL Next actually serves, not the folder tree.

next-list — artisan route:list for Next.js

npx next-list

next-list listing page routes

Why v2

The original tool was a single index.js from late 2024. Next.js moved on (proxy.ts, 'use cache', forbidden, MDX pages) and two things users actually asked for were broken:

  1. Export to a file dumped ANSI codes into routes.md (#1)
  2. Route groups like (marketing) leaked into the path, so /(pages)/championships/[legacyUrl]/(with-layout)/calendar was printed instead of /championships/[legacyUrl]/calendar (#2)

v2 rebuilds the scanner around current App Router conventions and adds the outputs other tools can consume.

Features

  • Pages, route.ts handlers and special files (proxy, sitemap, robots, OG images, instrumentation)
  • Correct URLs: strips (route-groups), keeps @parallel and intercepts as flags
  • Color-coded [param], [...catch], HTTP methods
  • Client vs server, metadata / generateMetadata, 'use cache', server actions, loading/error UI
  • JSON, markdown, tree, stats — and --out file.md with no escape codes
  • GitHub Action that writes a job summary and can sticky-comment a PR
  • Programmatic API: const { scan } = require('next-list')

Screenshots

Pages (groups stripped, intercepts as flags):

Page route table

Route handlers with method colors and Edge runtime:

API route table

Machine-readable stats for other tools:

JSON stats output

GitHub Action on a pull request:

GitHub Action snippet

Install

npx next-list
npm install -g next-list
next-list
{
"scripts": {
"routes": "next-list --stats"
}
}

Requires Node 18+ and a Next.js app with app/ or src/app/.

Usage

next-list [pages|api|special] [options]
FlagWhat it does
pages / api / specialShow one table instead of all three
-f, --fullPrefix with BASE_URL or APP_URL
-j, --jsonJSON (good for scripts)
-m, --mdGitHub-flavored markdown
-t, --treeFilesystem tree + resolved URL
--statsCounts after the table
--verbosedynamic, revalidate, fetchCache, runtime, file
--groupsKeep (route-groups) in the path
--fsShow folder paths instead of URLs
--filter <text>Substring match on URL or file
-o, --out <file>Write a file (markdown unless --json)
--dir <path>Project root (default: cwd)
--no-colorDisable ANSI (also automatic when piping)
npx next-list
npx next-list api --json
npx next-list --md --out routes.md
npx next-list --filter /blog --stats

Piping or --out turns colors off, so this stays a clean markdown table:

npx next-list --md > routes.md

GitHub Action

# .github/workflows/routes.ymlname: Routeson: [pull_request]jobs:
list:
runs-on: ubuntu-latestpermissions:
contents: readpull-requests: writesteps:
- uses: actions/checkout@v4
- uses: pablolizardo/next-list@v2with:
comment: true
InputDefault
project-path.Next.js project directory
commentfalseSticky-comment the PR (updates in place)
filterSubstring filter
groupsfalseKeep route groups in paths

The action always appends the table to $GITHUB_STEP_SUMMARY.

Programmatic API

const{ scan, render }=require('next-list')constdata=scan({dir: process.cwd()})console.log(data.stats)// { pages: 9, api: 4, special: 8, client: 1, server: 8, ... }constmarkdown=render(data,{markdown: true,command: 'all',color: false})

scan() returns { appDir, pages, api, special, stats }. Each page includes url, file, functionName, client, metadata, UI flags, parallel, intercept, and segment config (dynamic, revalidate, runtime, 'use cache').

What it understands

KindFiles
Pagespage.{js,jsx,ts,tsx,mdx}
Handlersroute.{js,ts}GET/POST/… including export const { GET, POST } = handlers
UIloading, error, not-found, forbidden, unauthorized, template, default
Next.js 16proxy.ts (and legacy middleware.ts)
Metadatasitemap, robots, opengraph-image, icon, instrumentation

Private folders (_components) are skipped. Route groups are omitted from the URL unless you pass --groups.

Brand

Colors, mark and wordmark live in brand/. Ink #10140F, paper #EDE6D2, lime #D6FF3F, copper #C45C26.

next-list brand kit

Contributing

npm install
npm test
node bin/next-list.js --dir fixtures/demo-app --stats

Bug reports and PRs: github.com/pablolizardo/next-list.

License

MIT © Pablo Lizardo

About

A command-line utility to explore and visualize all routes in your Next.js application, including both pages and API routes.

Resources

Stars

31 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages