Open-Source Wikis

/

Next.js

/

How to contribute

/

Tooling

vercel/next.js

Tooling

The repository's developer tooling spans pnpm + Turborepo for orchestration, Cargo for Rust, taskr for the publish pipeline, and a Husky pre-commit hook tying it all together.

Package management

  • pnpm 10.33.0 — pinned via packageManager in package.json. The repo is a pnpm workspace with packages/* as members (defined in pnpm-workspace.yaml).
  • Lockfilepnpm-lock.yaml (1.3MB). Updated by pnpm install. Touched by ~200 commits in the last 90 days, reflecting frequent dep updates.
  • Lerna — used for legacy pnpm types orchestration via lerna run types. The repo is migrating away from Lerna toward Turborepo.

Turborepo

turbo.json defines the task graph. The most-used targets:

Target What it does
pnpm build turbo run build — JS build of every package
pnpm build-all turbo run build build-native-auto — JS + Rust native builds
pnpm dev turbo run dev --parallel — watch mode for every package
pnpm lint-typescript turbo run typescript
pnpm storybook Storybook for @next/bundle-analyzer-ui

Caching is keyed against task inputs and uses Vercel's remote cache when configured. --remote-cache-timeout 60 is the default.

Build pipeline (taskr)

packages/next/ uses taskr for its publish pipeline, configured via packages/next/taskfile.js. Common invocations:

pnpm --filter=next exec taskr <task>      # run a specific taskr task
pnpm --filter=next build                  # full taskr build (60s cold)
pnpm --filter=next dev                    # watch mode (1-2s/change)
pnpm --filter=next types                  # tsc only (10s)

Notable tasks include compile, copy_vendor_react, and check_error_codes.

Cargo and Rust

Crate workspace Where Built by
Next.js Rust Cargo.toml (root) pnpm swc-build-nativecargo build
Turbopack subtree included in workspace same
next-error-code-swc-plugin excluded from workspace crates/next-error-code-swc-plugin/build-and-move.sh
rspack/crates/binding excluded from workspace rspack-specific build path

The Rust toolchain is pinned to nightly-2026-04-02 in rust-toolchain.toml. rustup will install it on first invocation.

WebAssembly builds: pnpm swc-build-wasm (script: scripts/build-wasm.cjs).

Linters

Linter Config file Command
Prettier .prettierrc.json, .prettierignore pnpm prettier-check, pnpm prettier-fix
ESLint eslint.config.mjs pnpm lint-eslint .
ESLint (CLI files) eslint.cli.config.mjs included in pnpm lint-eslint
ast-grep sgconfig.yml pnpm lint-ast-grep
TypeScript tsconfig.json pnpm types / pnpm types-and-precompiled
alex (language) .alexrc, .alexignore pnpm lint-language
Rust fmt .rustfmt.toml cargo fmt
Rust clippy (workspace lints in Cargo.toml) cargo clippy
Custom (next-error-codes) packages/next/check-error-codes.js pnpm check-error-codes

pnpm lint runs the full pack via npm-run-all. pnpm lint-fix runs prettier-fix and eslint --fix.

Pre-commit

Husky hook at .husky/pre-commit invokes pnpm lint-staged. The lint-staged config (lint-staged.config.js) runs prettier-fix and eslint-fix on the staged files. Each invocation takes ~2 minutes.

To pre-validate without triggering the hook:

pnpm prettier --with-node-modules --ignore-path .prettierignore --write <files>
npx eslint --config eslint.config.mjs --fix <files>

If lint-staged fails, the commit is aborted. Re-run after fixing.

Code generators

Generator What it produces Command
turbo gen test New test fixture + *.test.ts skeleton pnpm new-test
turbo gen error New error-code page under errors/ pnpm new-error
next-error-code-swc-plugin Rewrites errorCode(...) calls into stable IDs pnpm build-error-code-plugin
Native binary postinstall Builds or downloads next-swc native scripts/install-native.mjs (auto)

CI

GitHub Actions workflows live under .github/workflows/. The big ones:

Workflow Trigger What it does
build_and_test.yml Pull request Build + lint + test matrix (Turbopack, webpack, rspack)
build_and_deploy.yml Tag push Production releases
build_reusable.yml Reused Shared build steps
integration_tests_reusable.yml Reused Per-test-suite job templates
setup-nextjs-build.yml Reused Workspace bootstrap
retry_test.yml Manual Retry a single failing test
test_examples.yml Pull request Build the changed examples
release-next-rspack.yml Tag push rspack-specific releases
sync_backport_canary_release.yml Schedule Backports between canary and stable
update_react.yml Schedule Bumps the vendored React version
pull_request_stats.yml Pull request Bundle-size diff comments

Test results are uploaded via upload-tests-manifest.yml and update-bundler-manifest.js.

PR-status tooling

scripts/pr-status.js (47KB) analyzes a PR's CI failures and review comments and writes per-PR analysis files into scripts/pr-status/. Used by the pr-status-triage agent skill:

node scripts/pr-status.js          # auto-detect from current branch
node scripts/pr-status.js <number>

Triage rule: build > lint > types > tests, in priority order. Reproduce locally with the same env vars the failing job uses.

Release tooling

Script Role
release.js Orchestrates the release
scripts/start-release.js Starts a release on a branch
scripts/publish-release.js Publishes the release to npm
scripts/publish-native.js Publishes the platform-specific native binaries
scripts/code-freeze.js Locks the canary branch during release windows
scripts/check-backport-canary-release.js Validates backport correctness
scripts/generate-release-log.mjs Creates the changelog

The release flow runs through .github/workflows/build_and_deploy.yml and .github/workflows/trigger_release.yml.

Repo helpers

Helper What it does
pnpm git-reset git reset --hard HEAD
pnpm git-clean Cleans untracked except node_modules and packages
pnpm clean lerna clean -y + per-package clean + remove dist/
pnpm sweep Runs scripts/sweep.cjs to deduplicate similar fixtures
pnpm pack-next Packs Next.js to a tarball for testing
pnpm patch-next Applies local patches for downstream testing
pnpm sync-react Bumps the vendored React version
pnpm update-google-fonts Refreshes font metadata in packages/font/
pnpm next-with-deps Pack Next.js, link into a target project, run next there

Editor configuration

  • .editorconfig (in turbopack/) sets indent style for Rust files.
  • .vscode/ contains shared launch configs and recommended extensions.
  • .cursor/ provides Cursor-specific rules.
  • .devcontainer/ defines a Codespaces / Dev Containers setup with Node + Rust + pnpm pre-installed.

Storybook

The bundle analyzer UI uses Storybook:

pnpm storybook         # turbo run storybook
pnpm build-storybook   # turbo run build-storybook
pnpm test-storybook    # turbo run test-storybook

Configured per-package; the active package is packages/next-bundle-analyzer-ui (referenced in the dev script's --filter=!@next/bundle-analyzer-ui excludes).

Adapter

The packages/next/src/build/adapter/ directory implements the Next.js adapter API — the contract between the framework's build output and hosting platforms. Vercel implements this externally; other platforms can target the same surface. See packages/next/src/build/adapter/build-complete.ts (2,215 lines) for the full surface.

Built by Factory AutoWiki from public repository content. It is a generated preview for codebase exploration, not source-maintained documentation.

Tooling – Next.js wiki | Factory