Next.js is the React framework maintained by Vercel, developed as a TypeScript and Rust monorepo where a native Rust workspace implements the Turbopack bundler and SWC-based compiler alongside the existing Webpack and Rspack build paths.
- Language
- JavaScript
- Hosting
- Vercel
- License
- MIT
- Running for
- 8 years
- Team
- 1M+ MAU
Why this architecture
Performance-critical compilation and bundling are implemented as Rust crates (Turbopack, SWC transforms) compiled to native addons, while the framework surface stays in TypeScript, letting Next.js run its full test matrix across three interchangeable bundlers without forking the codebase.
Tech stack by layer
10 technologies · audited Sep 17, 2026- ReactThe framework Next.js extends; app-router and pages-router features build on React APIs.(inferred)
- TypeScriptImplements the next package CLI, server runtime, and most of the framework surface.
- Node.jsRuntime for the next CLI and server; the pinned version is tracked in .node-version.
- RustImplements Turbopack and SWC-based transforms as native crates compiled via napi bindings.
- TurborepoRuns generator-based scripts (turbo gen error, turbo gen test) though the monorepo build itself is orchestrated by Lerna.
- VercelPublishes the repository as a Vercel-made project; GitHub app settings for CI are checked into vercel.json.
- WebpackDefault bundler for next build and next dev, alongside the Turbopack and Rspack alternatives.
- RspackAlternate Rust-based bundler exercised by dedicated build/dev/test scripts and CI workflows.
Next.js architecture diagram
Open SVGDiagram as text
- create-next-app (ncc-bundled CLI) → Next.js app (React · app/ · pages/): scaffold
- Next.js app (React · app/ · pages/) → next CLI & server (TypeScript · Node.js): next dev / build
- next CLI & server (TypeScript · Node.js) → napi bindings (Rust to Node addon): native calls
- napi bindings (Rust to Node addon) → SWC transforms (Rust · custom transforms): transform
- napi bindings (Rust to Node addon) → Turbopack (Rust crates · next-core): bundle
- next CLI & server (TypeScript · Node.js) → Webpack · Rspack (default · alternate): bundle
- Turbopack (Rust crates · next-core) → Build output (.next/ server + static): emit
- Webpack · Rspack (default · alternate) → Build output (.next/ server + static): emit
- Build output (.next/ server + static) → Deploy target (Vercel · Node.js server): next start
Key architectural decisions
6 decisions- 01
Turbopack and SWC are implemented as Rust crates, not JS
Cargo.toml defines a Rust workspace including crates/next-core, crates/next-custom-transforms, crates/next-napi-bindings, and the turbopack/crates/* family, compiled to native Node addons; this is why Rust is the third-largest language in the repository by bytes.
- 02
Three bundlers are supported and tested side by side
The root package.json defines test-*-webpack, test-*-turbo, and test-*-rspack script variants (test-dev-webpack, test-dev-turbo, test-dev-rspack, etc.), and rspack/package.json and rspack-nextjs-build-integration-tests.yml show Rspack is exercised as a distinct bundler option alongside Webpack and Turbopack.
- 03
Monorepo tooling mixes Lerna, Turborepo generators, and pnpm workspaces
lerna.json and the clean script (lerna clean -y && lerna run clean) drive package-level operations, while turbo.json defines cacheable build/dev tasks and package.json also exposes turbo gen error and turbo gen test generators; pnpm-workspace.yaml lists packages/* as the workspace root.
- 04
create-next-app is a standalone, minimally-dependent CLI package
packages/create-next-app/package.json bundles its CLI with @vercel/ncc into a single dist/index.js, keeping its dependency surface (commander, prompts, cross-spawn, tar) separate from the main next package so project scaffolding stays fast to install.
- 05
The test suite runs against every bundler and every rendering mode
Root package.json scripts combine mode (test-dev, test-start, test-deploy) with bundler (webpack, turbo, rspack) to produce a matrix like test-dev-turbo and test-deploy-webpack, run through scripts/run-jest.sh against the Jest-based integration suite in test/.
- 06
create-next-app and font packages ship as separate npm publishes
packages/create-next-app, packages/font, and packages/eslint-config-next each have their own package.json and are published independently of the main next package, letting scaffolding, font optimization, and lint config version separately.
How Next.js is built
How Next.js is structured
The vercel/next.js repository is a large monorepo combining JavaScript/TypeScript packages with a native Rust workspace. Cargo.toml at the repository root defines the Rust workspace members, including crates/next-api, crates/next-build, crates/next-core, crates/next-custom-transforms, and the turbopack/crates/* family that implements the Turbopack bundler, plus crates/wasm for a WebAssembly target. On the JavaScript side, packages/create-next-app ships the project scaffolding CLI, packages/font handles font optimization, and packages/eslint-config-next and packages/eslint-plugin-next provide the framework's lint rules. The workspace also contains bench/ (a large collection of performance benchmarking fixtures such as bench/nested-deps-app-router and bench/render-pipeline), examples/ (dozens of reference integrations, from examples/cms-contentful to examples/cache-handler-redis), and errors/ (one Markdown file per documented framework error code, such as errors/dynamic-server-error.mdx).
Frontend
Next.js itself is the framework layer that applications built with React consume; the root package.json scripts reference React indirectly through the next CLI ("next": "cross-env NEXT_PRIVATE_LOCAL_DEV=1 ... next") and the framework's own test fixtures. The packages/create-next-app CLI is the primary entry point for scaffolding new projects, bundled as a single file with @vercel/ncc ("build": "ncc build ./index.ts -o ./dist/ --minify") so installing it stays fast. Fonts are handled by the separate packages/font package, keeping Google Fonts integration decoupled from the core framework release cycle.
Backend & APIs
The framework's request handling, routing, and build pipeline are implemented primarily in TypeScript, while performance-sensitive compilation is delegated to Rust. The swc_core dependency (pinned to version 79.0.0 in Cargo.toml) drives source transforms, and the Turbopack crates (turbopack-core, turbopack-ecmascript, turbopack-css, turbopack-node, and others under turbopack/crates/) implement the incremental bundler used by next dev --turbo and increasingly by next build. Native code is exposed to the JavaScript CLI through crates/next-napi-bindings. Release profiles in Cargo.toml are tuned per-crate (for example, opt-level = "s" for lightningcss, wasmtime, and several swc_* crates) to balance binary size against compile time, based on cargo bloat measurements noted directly in the file's comments.
Data & persistence
The framework itself is not backed by an application database; data-layer patterns (fetch caching, cache_handler) are an application-level concern documented under errors/ and demonstrated by example projects such as examples/cache-handler-redis, rather than a database dependency built into the next package. The examples/ directory as a whole (over a hundred subdirectories, including examples/cms-contentful, examples/cms-agilitycms, and examples/auth-with-stytch) functions as the framework's reference integration surface for the databases, headend CMSes, and auth providers it is commonly paired with, kept outside the core next package so those integrations can be updated without a framework release.
Build, test & deploy
The root package.json defines an extensive script matrix combining rendering mode (test-dev, test-start, test-deploy) with bundler (webpack, turbo, rspack), for example test-dev-turbo and test-deploy-webpack, all funneled through scripts/run-jest.sh into a Jest-based suite under test/. rspack/package.json and workflows like rspack-nextjs-build-integration-tests.yml and rspack-nextjs-dev-integration-tests.yml show Rspack is validated as a genuine third bundler, not just an experiment. Native crates are built with pnpm swc-build-native and pnpm swc-build-wasm, and build_and_deploy.yml plus test_e2e_deploy_release.yml cover release and deployment-flavored end-to-end tests. Monorepo orchestration mixes lerna (lerna.json, used for lerna clean and lerna run) with Turborepo (turbo.json, which defines cacheable build, dev, and typescript tasks) on top of a pnpm-workspace.yaml that scopes the workspace to packages/*.
Self-hosting notes
vercel.json in the repository root only configures GitHub app behavior ("github": { "silent": true, "autoJobCancelation": true }) for Vercel's own CI integration with this open-source repository; it is not an application deployment manifest, so it does not indicate that Next.js applications require Vercel to run. The framework supports a standard Node.js server output as well as static export, and self-hosting behavior is covered by the test_e2e_deploy_release.yml and retry_deploy_test.yml workflows, which run the same integration suite against deploy-flavored builds.
Sources & repo audit
- Root package.json (workspaces, multi-bundler test scripts)
- Root Cargo.toml (Rust workspace for Turbopack and SWC crates)
- vercel.json (GitHub app CI settings)
- turbo.json (task graph for build, dev, and typescript checks)
- packages/create-next-app/package.json (standalone scaffolding CLI)
Independent analysis of repository at github.com/vercel/next.js. Spotted an inaccuracy? Use the claim form to request a correction.
Show this stack on your README or website
[](https://stackitfast.com/project/nextjs)Paste it into your README. It shows your current stack and links to this page.
Scaffold it with your agent
Paste this prompt into Claude Code, Cursor, Windsurf or AGY to start a project with Next.js's architecture.
- 1Copy the promptThe full markdown spec, with every layer and decision.
- 2Open your AI toolClaude Code, Cursor, Windsurf or Copilot, in a new repo.
- 3Paste and scaffoldUse it as the first instruction; review before you ship.
# MISSION: Scaffold "Next.js" Production Architecture
You are an expert Senior Staff Software Architect and Full-Stack Engineer. Your mission is to scaffold and implement a production-grade, highly reliable, and modular codebase following the proven architecture of **Next.js**.
---
## 1. PROJECT SPECIFICATIONS & BENCHMARK
- **Reference Architecture**: Next.js
- **What It Does**: Next.js is the React framework maintained by Vercel, developed as a TypeScript and Rust monorepo where a native Rust workspace implements the Turbopack bundler and SWC-based compiler alongside the existing Webpack and Rspack build paths.
- **Domain & Category**: Fullstack React Framework
- **Production Scale**: 1M+ MAU
- **Development Mode**: HYBRID
- **Architectural Rationale**: Performance-critical compilation and bundling are implemented as Rust crates (Turbopack, SWC transforms) compiled to native addons, while the framework surface stays in TypeScript, letting Next.js run its full test matrix across three interchangeable bundlers without forking the codebase.
- **Live Website Reference**: https://nextjs.org
- **Source Repository**: https://github.com/vercel/next.js
---
## 2. PRODUCTION TECH STACK
- **Full Stack Array**: TypeScript, JavaScript, React, Node.js, Rust, Webpack, Rspack, Jest, Vercel, Turborepo
- **Primary Language(s)**: JavaScript, TypeScript, Rust
- **License of the reference repo**: MIT
- **Frontend**: React — The framework Next.js extends; app-router and pages-router features build on React APIs.
- **Backend & APIs**: TypeScript — Implements the next package CLI, server runtime, and most of the framework surface.; Node.js — Runtime for the next CLI and server; the pinned version is tracked in .node-version.; Rust — Implements Turbopack and SWC-based transforms as native crates compiled via napi bindings.
- **Infrastructure & deploy**: Turborepo — Runs generator-based scripts (turbo gen error, turbo gen test) though the monorepo build itself is orchestrated by Lerna.; Vercel — Publishes the repository as a Vercel-made project; GitHub app settings for CI are checked into vercel.json.; Webpack — Default bundler for next build and next dev, alongside the Turbopack and Rspack alternatives.; Rspack — Alternate Rust-based bundler exercised by dedicated build/dev/test scripts and CI workflows.
---
## 3. KEY ARCHITECTURAL DECISIONS (audited from https://github.com/vercel/next.js @ d5b615e)
1. **Turbopack and SWC are implemented as Rust crates, not JS**: Cargo.toml defines a Rust workspace including crates/next-core, crates/next-custom-transforms, crates/next-napi-bindings, and the turbopack/crates/* family, compiled to native Node addons; this is why Rust is the third-largest language in the repository by bytes.
2. **Three bundlers are supported and tested side by side**: The root package.json defines test-*-webpack, test-*-turbo, and test-*-rspack script variants (test-dev-webpack, test-dev-turbo, test-dev-rspack, etc.), and rspack/package.json and rspack-nextjs-build-integration-tests.yml show Rspack is exercised as a distinct bundler option alongside Webpack and Turbopack.
3. **Monorepo tooling mixes Lerna, Turborepo generators, and pnpm workspaces**: lerna.json and the clean script (lerna clean -y && lerna run clean) drive package-level operations, while turbo.json defines cacheable build/dev tasks and package.json also exposes turbo gen error and turbo gen test generators; pnpm-workspace.yaml lists packages/* as the workspace root.
4. **create-next-app is a standalone, minimally-dependent CLI package**: packages/create-next-app/package.json bundles its CLI with @vercel/ncc into a single dist/index.js, keeping its dependency surface (commander, prompts, cross-spawn, tar) separate from the main next package so project scaffolding stays fast to install.
5. **The test suite runs against every bundler and every rendering mode**: Root package.json scripts combine mode (test-dev, test-start, test-deploy) with bundler (webpack, turbo, rspack) to produce a matrix like test-dev-turbo and test-deploy-webpack, run through scripts/run-jest.sh against the Jest-based integration suite in test/.
6. **create-next-app and font packages ship as separate npm publishes**: packages/create-next-app, packages/font, and packages/eslint-config-next each have their own package.json and are published independently of the main next package, letting scaffolding, font optimization, and lint config version separately.
---
## 4. NON-NEGOTIABLE ARCHITECTURAL GUARDRAILS
1. **Monorepo & Modular Separation**:
- Structure as a Turborepo monorepo with strict package boundaries:
- `apps/web`: Application UI, routing, layouts, and server endpoints.
- `packages/ui`: Shared design tokens, CSS variables, and Radix UI primitive components.
- `packages/db`: Database schemas, client singleton, declarative migrations, and seed scripts.
- `packages/config`: Shared TypeScript, ESLint, and build configurations.
2. **Strict Type Safety & Zero `any` Policy**:
- Enable `strict: true`, `noImplicitAny: true`, and `strictNullChecks: true`.
- Validate ALL external inputs, API request bodies, and query parameters with **Zod** schemas before execution.
3. **Frontend & Rendering Guidelines**:
- Isolate interactive UI state to leaf components. Keep core pages lightweight and performant.
4. **Design System & Aesthetics**:
- Keep every color, radius, shadow and font in a single token file (CSS variables) and consume tokens everywhere; never hardcode hex values in components.
- Prefer crisp 1px borders and one subtle shadow scale over blurry default shadows. Pair one sans-serif for body/headings with one monospace for tags, badges, metrics, and code.
5. **Data Layer & Reliability**:
- Write declarative schema definitions with foreign keys, composite indexes on queried filters, and automated timestamp triggers.
- Use connection pooling and prepared statements for serverless database execution.
---
## 5. STEP-BY-STEP SCAFFOLDING ROADMAP
- **Phase 1: Workspace & Root Config**: Initialize package manager, monorepo configuration (`turbo.json`, `tsconfig.base.json`, `package.json`).
- **Phase 2: Database Schema & Client**: Set up the data layer: client, connection pool, models, and migration scripts.
- **Phase 3: Design Tokens & UI Primitives**: Build accessible `Button`, `Input`, `Card`, `Badge`, and layout wrappers inside `packages/ui`.
- **Phase 4: Core Application Routes & Handlers**: Implement primary authentication, user session handling, and application routes.
- **Phase 5: Quality Assurance & Build Verification**: Run `tsc --noEmit`, ESLint, Prettier, and smoke test suites to ensure zero compilation or runtime errors.
---
## 6. EXECUTION INSTRUCTIONS
1. Review all specifications, architectural guardrails, and stack choices above.
2. Present the full monorepo directory tree structure.
3. Systematically generate the complete, production-ready codebase according to the 5-phase roadmap above — starting with the root workspace setup, followed by the database schema, UI design system package, and full-stack application routes until the repository is fully scaffolded and ready to run.Frequently asked about Next.js
What tech stack does Next.js use?
Next.js is built with TypeScript and JavaScript for the framework surface, with a Rust workspace (Cargo.toml) implementing Turbopack and SWC-based compilation as native Node addons, plus Webpack and Rspack as alternative bundlers.
Is Next.js built with Turbopack, Webpack, or Rspack?
All three. The repository maintains separate test scripts and CI workflows for each bundler (for example test-dev-turbo, test-dev-webpack, test-dev-rspack), with Turbopack implemented in the Rust workspace defined in Cargo.toml.
Is Next.js tied to Vercel for deployment?
The repository is developed by Vercel and includes a vercel.json for its own GitHub CI integration, but that file only configures repository automation, not an application deployment target.
What monorepo tooling does the Next.js repository use?
It combines Lerna (lerna.json, used for per-package clean and version scripts) with Turborepo (turbo.json) for cacheable build and generator tasks, on top of a pnpm workspace defined by pnpm-workspace.yaml.
One email a month: new deep dives and stack trends
New source-audited architectures, head-to-head comparisons and the monthly stack report. No spam, unsubscribe anytime.
Similar architectures
- Tailwind CSSClassicUtility-First CSS Engine & Framework · 1M+ MAUShares TypeScript · Rust · Turborepo
- ExcalidrawClassicCanvas Editor · 2-5 peopleShares React · TypeScript · Vercel
- DenoClassicSecure JavaScript & TypeScript Runtime · 20+ peopleShares Rust · TypeScript
- BunClassicAll-in-One JavaScript Runtime & Toolchain · 1M+ MAUShares Rust · TypeScript
- PenpotClassicDesign & Prototyping Platform · 20+ peopleShares Rust · TypeScript
- UplevelerHybridDeveloper Work Log & Promotion Coach · SoloShares Rust