Next.js: extract page routes (app/page.tsx, pages/*.tsx)#6
Conversation
Extend the Next.js extractor to discover user-visible page routes:
App Router:
- Scan app/**/page.{tsx,jsx,ts,js} files
- Emit as { method: 'GET', handler: 'Page', kind: 'page' }
- Exclude layout files (layout, template, loading, error, not-found, default)
Pages Router:
- Scan pages/**/*.{tsx,jsx,ts,js} files
- Exclude pages/api/ (already handled as API endpoints)
- Exclude special files (_app, _document, _error, _middleware)
- Normalize /index segments (pages/about/index.tsx -> /about)
Also adds test fixture and 21 tests covering all extraction scenarios.
Co-authored-by: Jorge Alejandro Raad <jorge@pensarai.com>
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
Bugbot Autofix is ON. A cloud agent has been kicked off to fix the reported issue.
Reviewed by Cursor Bugbot for commit 062b4ec. Configure here.
| // Skip special Next.js files | ||
| if (PAGES_ROUTER_SPECIAL_FILES.has(stem)) continue; | ||
| // Skip layout-like files in pages router | ||
| if (APP_ROUTER_LAYOUT_FILES.has(stem)) continue; |
There was a problem hiding this comment.
App Router exclusions incorrectly applied to Pages Router
Low Severity
The APP_ROUTER_LAYOUT_FILES set (layout, template, loading, error, not-found, default) is applied to filter Pages Router files, but these are only reserved names in the App Router. In Pages Router, files like pages/error.tsx or pages/loading.tsx are perfectly valid pages (only _error.tsx with underscore is special). This causes legitimate Pages Router pages with these stems to be silently excluded from extraction results, including in nested paths like pages/dashboard/loading.tsx.
Additional Locations (1)
Reviewed by Cursor Bugbot for commit 062b4ec. Configure here.
* feat: add kind field (api | page | action | websocket) to EndpointInfo - Add EndpointKind type to types.ts - Add required kind field to EndpointInfo interface - Add optional kind? parameter to endpoint() factory (defaults to 'api') - Set kind: 'action' in server-actions extractor - Set kind: 'websocket' for FastAPI websocket routes - Include kind in JSON/NDJSON output for both map and impact formatters - Export EndpointKind from public API (index.ts) Co-authored-by: Jorge Alejandro Raad <jorge@pensarai.com> * feat(nextjs): extract page routes from app/ and pages/ directories (#6) Extend the Next.js extractor to discover user-visible page routes: App Router: - Scan app/**/page.{tsx,jsx,ts,js} files - Emit as { method: 'GET', handler: 'Page', kind: 'page' } - Exclude layout files (layout, template, loading, error, not-found, default) Pages Router: - Scan pages/**/*.{tsx,jsx,ts,js} files - Exclude pages/api/ (already handled as API endpoints) - Exclude special files (_app, _document, _error, _middleware) - Normalize /index segments (pages/about/index.tsx -> /about) Also adds test fixture and 21 tests covering all extraction scenarios. Co-authored-by: Cursor Agent <cursoragent@cursor.com> --------- Co-authored-by: Cursor Agent <cursoragent@cursor.com>


Summary
Extends the Next.js extractor to discover user-visible page routes that were previously missing from extraction output. The extractor now scans both App Router and Pages Router page files in addition to the existing API route scanning.
Changes
App Router pages (
app/**/page.{tsx,jsx,ts,js})app/andsrc/app/directories forpage.{tsx,jsx,ts,js}files{ method: "GET", handler: "Page", kind: "page" }app/blog/[slug]/page.tsx→/blog/[slug])layout,template,loading,error,not-found,defaultPages Router pages (
pages/**/*.{tsx,jsx,ts,js})pages/andsrc/pages/directoriespages/api/(already handled as API endpoints)_app,_document,_error,_middleware/indexsegments:pages/about/index.tsx→/about,pages/index.tsx→/{ method: "GET", handler: "Page", kind: "page" }Test coverage
nextjs-pagesfixture with realistic App Router + Pages Router structure[slug])/indexnormalization_app,_document, andapi/directoryOther
scripts/fixturestotsconfig.jsonexclude list (fixture TSX files don't have React types)Depends on
cursor/add-kind-field-4943(thekindfield onEndpointInfo)