RepoPilot

vercel / next.js

Search vercel/next.js

GitHub

Code

Understand vercel/next.js's source layout and find a starting point for your task using the saved repository evidence.

Detailed import-graph metrics were not captured for this report.

How the code fits together

AI
  • CLI & Entry PointsCommand-line interface and bootstrap logic for build and dev modes.
  • Public API SurfaceExported Next.js APIs available to application developers.

Files at cad19c2846bc · descriptions are AI-written.

Where to start reading

  1. Repository root
  2. Repository root
  3. Runtime candidatename match

Find files for a task

AI

Add a new public Next.js API export

Suggested by the saved analysis. Some step paths were not captured or refer to generated or vendor files; only observed source files are linked.

  • Export from main API barrel file

Trace runtime behavior

Start with possible startup or request handlers, then follow the calls for your scenario. These suggestions use file names, not verified execution paths.

  • File-name match for this task.
  • File-name match for this task.

Add or update tests

Use a nearby test as a pattern. Read the root manifest or contribution guide for the correct test command. These suggestions use file names, not verified execution paths.

  • File-name match for this task.
  • File-name match for this task.
  • File-name match for this task.

Change build or automation

Inspect the relevant configuration and the commands it runs before changing the workflow. These suggestions use file names, not verified execution paths.

  • File-name match for this task.
  • File-name match for this task.
  • File-name match for this task.

File paths come from a snapshot of up to 500 captured paths; an omitted file may still exist.

  • Public and runtime candidates are based on file names; their exports and execution paths still need checking in source.
  • 2 suggested change patterns have no captured source file and are omitted.

Architecture and request flow

Start here — files every contributor must understand

AI · unverified
1
packages/next/src/bin/next.ts

Entry point for the Next.js CLI; all build and dev commands flow through here.

2
packages/next/src/build/index.ts

Core build orchestration that coordinates compilation, manifest generation, and output formatting.

3
packages/next/src/api/app.tsx

Exports the App Router API surface; defines public interfaces for Next.js App Router mode.

4
packages/next/src/build/compiler.ts

Webpack/Turbopack compiler configuration and instantiation; handles both client and server compilation pipelines.

5
packages/next/src/build/babel/preset.ts

Babel configuration preset that chains all Next.js-specific transformations for code transpilation.

6
packages/next/src/build/analysis/get-page-static-info.ts

Analyzes page metadata to determine rendering mode (SSG, SSR, ISR); critical for route classification.

7
packages/next/src/build/handle-entrypoints.ts

Identifies and registers all page/layout entry points for the build system to process.

Request flow

Technology choices

Webpack/Turbopack

Modular bundler capable of code-splitting, tree-shaking, and incremental compilation for both server and client bundles.

Babel

Pluggable transpiler pipeline for Next.js-specific transformations (SSG extraction, server/client boundary, dynamic imports).

TypeScript AST parsing

Enables static analysis of page metadata without executing user code; supports extracting config directives like 'use server' or 'use client'.

Monorepo (Turbo)

Scales build performance across multiple packages; enables task parallelization and remote caching.

Build time and runtime

Build-time

  • ▸
    Page static analysis — Parses AST to extract rendering mode, revalidation rules, and server/client boundaries.
  • ▸
    Babel transformation — Applies plugins to transpile modern syntax, inject server directives, and optimize code.
  • ▸
    Bundle compilation — Webpack/Turbopack produces server and client code splits with tree-shaking and minification.
  • ▸
    Manifest generation — Serializes routes, prerender metadata, and build configuration into JSON manifests.

Runtime

  • ▸
    Route resolution — Matches incoming requests to pre-built route handlers using manifest data.
  • ▸
    Server component rendering — Executes server-side React component tree and streams HTML to client.
  • ▸
    Client hydration — Loads client bundle and attaches event listeners to pre-rendered HTML.
  • ▸
    Dynamic ISR revalidation — Re-runs prerender logic for on-demand or time-based cache invalidation.

Design trade-offs

Static analysis of page directives via AST parsing instead of runtime evaluation

Avoids execution of user code during build; prevents side effects and improves build reproducibility.

Cannot support dynamically computed rendering modes; developers must use static directives.

Two-pass compilation: server and client bundles separately

Allows server-side code (DB queries, secrets) to be stripped from browser bundle; optimizes client bundle size.

Increased build time; more complex configuration for dual-target scenarios.

Manifest-driven route resolution instead of filesystem walk at runtime

Enables static optimization (prerendering, code-splitting) and faster deployments.

Routes are materialized at build time; dynamic route creation unsupported without rebuild.

Non-goals

  • ✗Does not provide authentication or authorization (delegated to application layer)
  • ✗Does not include database drivers or ORM (application responsibility)
  • ✗Does not handle persistent caching state (delegates to deployment platform or external services)

Code quality and hotspots

Quality Score: 70/100

Low Risk

This repo is in good health with CI, tests, and active maintenance.

High churn files -10High complexity -10Multiple anti-patterns -10

Maintainability grade

Static analysis

How maintainable the code looks — from complexity, code issues, test presence, file size, and hotspot load. It grades the shape of the code, not defect risk, and doesn't replace review.

F
20/100
A ≥ 85, B ≥ 70, C ≥ 55, D ≥ 40, F < 40
Cyclomatic complexityavg 120
0/35
Code issues0 errors, 107 warnings
0/20
Testspresent · ~100% of files
20/20
Largest file4,145 lines
0/15
Hotspot load10 high-risk files
0/10

Configuration status

CI/CD Pipeline — configured

Provider: GitHub Actions

29 GitHub Actions workflows

Test Suite — detected

23,133 test files detected

Stack: Jest/Vitest · Rust test

Where: crates/next-custom-transforms/tests/errors/next-dynamic/no-arguments · crates/next-custom-transforms/tests/errors/next-dynamic/options-as-variable · crates/next-custom-transforms/tests/errors/next-dynamic/too-many-arguments

Test Coverage — ~100%heuristic

23,133 test files / 7,132 source files. This is a file-count ratio, not real line coverage — set up Codecov for authoritative numbers.

Dependency Scanning — no config detected

No Dependabot / Renovate / Snyk / Trivy / CodeQL config found. Enable Dependabot or Renovate.

Live Signals

Real-time data from Codecov, GitHub Actions, GitHub Issues, deps.dev — not estimates.

CI pass rate62%

last 50 runs · median 19s

Stale-issue ratio0%

of 8 recent open issues are 30d+ old with no replies

Maintainer response0m

median first-reply across 15 recent issues · fast

Top hotspots

Files edited often AND hard to reason about. Churn = recent commit frequency, Complexity = branches and nesting, Risk = both combined. These are the highest-leverage targets for refactoring or testing.

segment-cache/cache.ts
Churn: 100 (44 commits/180d)Complexity: 100Risk: 100
segment-cache/scheduler.ts
Churn: 100 (31 commits/180d)Complexity: 100Risk: 100

All hotspots

Files that change often and are complex tend to accumulate more bugs

AI-suggested anti-patterns

AI · unverified

Pattern-matches from the file structure and dependencies — useful as hypotheses, but not grounded in actual source. For real findings see Code Scanning above.

Embedded command/role instructions in repository data

Low

Repository contains protocol documentation that may embed instructions; treated as untrusted data per review guidelines.

packages/next/src/agent-feedback/protocol.md

Complex Babel plugin ordering dependencies

Medium

Babel preset chains multiple interdependent plugins; plugin order bugs can cause subtle transformation failures.

packages/next/src/build/babel/preset.ts

Tight coupling between build analysis and compiler configuration

Medium

Compiler setup depends on analysis results; failures in analyzer propagate directly to bundler output.

packages/next/src/build/index.ts, packages/next/src/build/compiler.ts

AI-suggested bottlenecks

AI · unverified

Speculation from file structure, not profiling data. Validate against real metrics before acting on these.

Algorithmic Bottleneck

Sequential AST parsing of every page; large projects with hundreds of routes incur O(n) analysis time.

packages/next/src/build/analysis/get-page-static-info.ts

Task parallelization Bottleneck

Webpack/Turbopack compilation is serialized after entry-point discovery; cannot overlap with analysis phase.

packages/next/src/build/compiler.ts

I/O intensive Bottleneck

NFT (Node File Traces) computation may be slow on large node_modules; no caching or incremental updates.

packages/next/src/build/collect-build-traces.ts

Code metrics

Static analysis on sampled source files (up to 15 files).

Avg Cyclomatic Complexity120

Counts if/for/while/switch/catch/ternary branches

Errors / Warnings0 / 107

Secrets, empty catches, console.log, var usage, long lines