Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
833 commits
Select commit Hold shift + click to select a range
4eedd9f
chore: update build config
pi0 Dec 17, 2025
0d9f782
build: generate type hints for nitro subpath exports
pi0 Dec 17, 2025
a335d7d
feat: allow custom ignore patterns for public assets (#3883)
danielroe Dec 17, 2025
ba755e6
refactor(vite): remove experimental vfs for now
pi0 Dec 17, 2025
0e6f159
build: fix vite asset types
pi0 Dec 17, 2025
e6336c7
ci: increase timeout to 10min
pi0 Dec 17, 2025
2058e20
chore: update meta import
pi0 Dec 17, 2025
1ee0b5b
chore: update deps
pi0 Dec 17, 2025
52d09c4
build: fix vite asset declaration
pi0 Dec 17, 2025
d33b983
chore: improve chunk names
pi0 Dec 17, 2025
8872365
perf(vite): patch assets plugin for hook filters
pi0 Dec 17, 2025
a41288c
chore: prettierignore pnpm files
pi0 Dec 17, 2025
3a9926b
chore(examples): remove `@ts-ignore` from asset imports
pi0 Dec 17, 2025
fea3934
build(vite): add vite client types
pi0 Dec 18, 2025
44509ce
build: empty js stub for `vite/types` subpath export
pi0 Dec 18, 2025
0d0a2f9
build: add vite type imports only to dts
pi0 Dec 18, 2025
ced5469
perf(rolldown): improve tree-shaking
pi0 Dec 18, 2025
0dfa69c
docs: update runtime config usage (#3885)
danielroe Dec 18, 2025
f4ceeee
chore: update hookable to v6 stable
pi0 Dec 18, 2025
7f42bc1
fix: handle void hook result
pi0 Dec 18, 2025
077b79b
fix: use `module` condition and main fields for bundling (#3886)
pi0 Dec 18, 2025
3992c73
refactor(types): avoid `DeepPartial` (#3888)
pi0 Dec 18, 2025
00598a8
fix: cache rou3 compilation by options hash (#3890)
danielroe Dec 19, 2025
9a930b2
refactor: update assets plugin for better tree shake (#3891)
hi-ogawa Dec 22, 2025
d148c81
chore: update deps
pi0 Dec 22, 2025
0f3740d
chore: update lockfile
pi0 Dec 22, 2025
2edbf99
chore(deps): update all non-major dependencies (#3889)
renovate[bot] Dec 24, 2025
fb6b85d
fix(openapi): only filter `undefined` from array nodes (#3894)
kricsleo Dec 24, 2025
0daf29e
chore: add initial `AGENTS.md` (#3896)
iiio2 Dec 24, 2025
1a1198e
chore: update url (#3898)
iiio2 Dec 26, 2025
9e2ab3f
docs(runtime-config): emphasize `NITRO_` env prefix requirement (#3906)
jamaluddinrumi Dec 30, 2025
eecf725
fix(vite): kill prerender child process when the vite preview server …
schiller-manuel Dec 30, 2025
74f2198
fix(vite): wait on preview child port to be ready (#3908)
schiller-manuel Dec 30, 2025
3fd0300
chore: update oxc to 0.106
pi0 Dec 30, 2025
d601b20
chore: update h3 tand srvx
pi0 Dec 30, 2025
1634441
chore: fix type issues
pi0 Dec 30, 2025
6e801e2
test: change proxy target
pi0 Dec 30, 2025
f4e95d0
chore: update eslint plugins
pi0 Jan 2, 2026
4e7a953
chore: update lint config
pi0 Jan 2, 2026
ba2fd56
chore: update vite and rolldown
pi0 Jan 2, 2026
2fb634a
build: force native fetch
pi0 Jan 2, 2026
301604f
fix(vite): trap unhandled errors in worker
pi0 Jan 2, 2026
656a71e
fix(dev): respect `opts.json` when `false` for error handler (#3920)
danielroe Jan 5, 2026
e440bc2
chore(deps): update all non-major dependencies (#3918)
renovate[bot] Jan 5, 2026
df7fd85
feat(vite): experimental rsc plugin support (#3919)
hi-ogawa Jan 5, 2026
72b037f
fix(vercel): add preview command (#3921)
pi0 Jan 5, 2026
02aef37
chore: update `vite-rsc` example (#3922)
hi-ogawa Jan 6, 2026
80f8922
feat: automatically trace known native pkgs (#3923)
pi0 Jan 6, 2026
056cfaf
chore: update deps
pi0 Jan 6, 2026
e9c3a66
build: remove `nf3` from peer dependencies
pi0 Jan 6, 2026
e20c92d
perf: lazy import unimport
pi0 Jan 6, 2026
5019d34
build: update obuild
pi0 Jan 6, 2026
a382e08
build: split vite entry
pi0 Jan 6, 2026
ea0e033
chore: update obuild
pi0 Jan 6, 2026
5325b20
build: fix chunks
pi0 Jan 6, 2026
b085a48
build: fix chunks
pi0 Jan 6, 2026
f91c7b6
chore: update deps
pi0 Jan 7, 2026
1c2f1c0
perf: process static assets in parallel (#3911)
tirojal Jan 7, 2026
67b43f2
feat(vite): auto-register server consumer environments as services (#…
schiller-manuel Jan 8, 2026
0874039
fix: collect errors in utils/parallel (#3933)
tirojal Jan 8, 2026
99691fc
feat(cloudflare): always augment request with cf context (#3904)
emretinaztepe Jan 9, 2026
f312cfb
chore: update dependencies (#3943)
pi0 Jan 13, 2026
a765d98
chore: add `vite-trpc` example (#3944)
pi0 Jan 13, 2026
e32021e
chore(deps): update all non-major dependencies (#3950)
renovate[bot] Jan 15, 2026
d5f9179
chore: update undocs (llms.txt and markdown support) (#3949)
pi0 Jan 15, 2026
0e06c71
fix: force trace `pg` dependency
pi0 Jan 15, 2026
00a9321
chore: update lockfile
pi0 Jan 15, 2026
4253b08
build: add pkg meta for vite plugin registry (#3951)
pi0 Jan 15, 2026
98fc91c
chore: update undocs
pi0 Jan 15, 2026
26241d6
chore: update deps
pi0 Jan 19, 2026
995944a
chore: update lockfile
pi0 Jan 19, 2026
d0c4950
docs(nightly): add note about bun package manager (#3960)
pi0 Jan 19, 2026
624b85a
chore: update deps
pi0 Jan 20, 2026
02475fa
refactor(rolldown): migrate to `codeSplitting` config
pi0 Jan 20, 2026
1cde6f6
types: fix commonjs options type import
pi0 Jan 20, 2026
9bbe655
chore: update h3 and oxc
pi0 Jan 20, 2026
6786d06
build: hotfix
pi0 Jan 20, 2026
cbfce96
build: update obuild
pi0 Jan 20, 2026
e5f6fee
chore: update deps
pi0 Jan 20, 2026
ca1a9de
build: show name of all grouped lib names
pi0 Jan 20, 2026
74e8d67
feat(vercel, netlify, cloudflare): support `req.ip` (#3952)
huseeiin Jan 20, 2026
795e774
feat(netlify-edge): support `req.ip` (#3946)
huseeiin Jan 20, 2026
d2383f0
refactor: include name of hoisted libs in chunk name (#3962)
pi0 Jan 20, 2026
722efdc
feat: rolldownConfig (#3887)
pi0 Jan 21, 2026
22bd0c6
fix: avoid naming `node_modules/.*` as lib chunk
pi0 Jan 21, 2026
b2b3788
fix: use static replacement for websocket feature (#3964)
pi0 Jan 21, 2026
28f908a
chore: update lockfile
pi0 Jan 21, 2026
c782414
chore(release): v3.0.1-alpha.2
pi0 Jan 21, 2026
21b0272
presets(vercel): add support for node@24 (#3967)
jvitormelo Jan 22, 2026
d4f5eaf
chore: support `presets` change type
pi0 Jan 22, 2026
3c506bb
fix(vite): remove chunk config when `inlineDynamicImports` enabled
pi0 Jan 22, 2026
a8c8cba
feat: add non bundlable dependencies from nf3 db
pi0 Jan 22, 2026
64df4cf
fix(vite): merge bundler config first before normalize
pi0 Jan 22, 2026
dfdff9e
fix: use `virtual:` prefix for raw plugin for vite compatibility
pi0 Jan 22, 2026
eec384a
chore: use `oxlint` and `oxfmt` (#3971)
pi0 Jan 23, 2026
c6b834c
chore: simplify `.oxlintrc`
pi0 Jan 23, 2026
9453237
presets(aws-lambda): avoid modifying response headers in streaming mo…
pi0 Jan 24, 2026
d6734a1
chore: update undocs
pi0 Jan 24, 2026
9c7d500
chore: update undocs
pi0 Jan 24, 2026
9c6abf1
chore: update docs lock
pi0 Jan 24, 2026
8882bc9
docs(cloudflare): remove invalid docs and add note about wrangler env…
RihanArfan Jan 25, 2026
ccc8fcc
chore: fix type issue
pi0 Jan 27, 2026
47dc1ee
chore: update deps
pi0 Jan 27, 2026
a19c48a
chore(examples): update deps
pi0 Jan 27, 2026
bbe8553
chore: update lockfile
pi0 Jan 27, 2026
ef01b09
chore: apply automated updates
autofix-ci[bot] Jan 27, 2026
ae83c97
chore: update deps
pi0 Jan 28, 2026
29724fb
chore(deps): update all non-major dependencies (#3982)
renovate[bot] Jan 28, 2026
8aa7b23
docs: fix lifecycle link on renderer page (#3992)
MiniDigger Jan 31, 2026
eea737f
chore: add ai config in gitignore (#3993)
iiio2 Jan 31, 2026
a1e4ca7
docs: add code splitting section (#3991)
onmax Jan 31, 2026
654aa75
chore: update deps
pi0 Jan 31, 2026
bae2370
chore: update deps
pi0 Feb 2, 2026
8e115e5
chore: migrate to tsgo
pi0 Feb 2, 2026
927a586
chore: update vite beta
pi0 Feb 2, 2026
6c1084c
ci: force vite 7 for rollup tests
pi0 Feb 2, 2026
2681716
chore: default vite to v8
pi0 Feb 2, 2026
1954b82
chore: always ignore vite-rsc for rollup
pi0 Feb 2, 2026
fa1fe63
chore: remove repo local security.md
pi0 Feb 3, 2026
0a64068
feat(vite): use srvx loader for preview (#3999)
pi0 Feb 5, 2026
6f14ea8
chore: update deps
pi0 Feb 5, 2026
ad756f6
ci: skip rsc test for now
pi0 Feb 5, 2026
6c80c11
refactor: add `rolldown` as dependency (#4002)
pi0 Feb 5, 2026
acd7198
fix: support PORT=0 for random port assignment (#4000)
wadefletch Feb 5, 2026
f5cf688
perf: optimize duplicate handler filtering (#4003)
OskarLebuda Feb 5, 2026
bbe5a7a
fix: remove deprecate `inlineDynamicImports` from rolldown config
pi0 Feb 5, 2026
e351b03
chore: update nf3
pi0 Feb 5, 2026
150b6f9
fix(vite): remove `keep-alive` header from worker
pi0 Feb 5, 2026
ac1665d
chore: update deps
pi0 Feb 5, 2026
5cb673e
build: remove rolldown from peer deps
pi0 Feb 5, 2026
8d92160
docs: add examples (#3984)
RihanArfan Feb 5, 2026
8deb70e
feat: support zstd for compressPublicAssets (#3934)
aaharu Feb 6, 2026
ef9a03f
chore: use `.agents/skills`
pi0 Feb 6, 2026
49b9250
chore: update deps
pi0 Feb 6, 2026
a25fb9e
chore: remove unused code
pi0 Feb 6, 2026
db30877
refactor(runner): use `node:http` to fetch worker (#4004)
pi0 Feb 6, 2026
241ef01
feat(vercel): rewrite `proxy` route rule on cdn (#4006)
RihanArfan Feb 6, 2026
5f615a7
fix(vite): set `copyPublicDir: false` by default (#4005)
sandros94 Feb 6, 2026
f2d32c3
chore: update deps
pi0 Feb 6, 2026
bc737c0
chore: add ref to `dist/THIRD-PARTY-LICENSES.md`
pi0 Feb 6, 2026
ade3568
build: update c12 and remove jiti dep
pi0 Feb 6, 2026
20e958e
chore: update lock
pi0 Feb 6, 2026
6135a8b
build: add jiti as an optional peer dep
pi0 Feb 9, 2026
9ad2aae
build: add windows backslash to regexes
pi0 Feb 9, 2026
acc1598
chore: apply automated updates
autofix-ci[bot] Feb 9, 2026
6e82161
chore: update deps
pi0 Feb 9, 2026
1f3e6d2
build: add `dotenv` to optional peer deps
pi0 Feb 9, 2026
99f7fe3
build: add giget to optional peer deps
pi0 Feb 9, 2026
e83117f
chore(deps): update autofix-ci/action digest to 7a166d7 (#4007)
renovate[bot] Feb 9, 2026
e102ff6
chore(deps): update all non-major dependencies (#4008)
renovate[bot] Feb 9, 2026
2586302
build: move `hookable` to dependencies and fix plugin hook docs (#4014)
wadefletch Feb 10, 2026
121495c
fix(vercel): fix preview mode compat with srvx (#4011)
renantatsuo Feb 10, 2026
f0f97cd
presets(vercel): add types and docs for `isr.exposeErrBody`
pi0 Feb 10, 2026
fe594c5
chore: update deps
pi0 Feb 10, 2026
f9762b2
chore: move `.prettierrc` to `.oxfmtrc.json`
pi0 Feb 10, 2026
2456c18
chore: fix types
pi0 Feb 10, 2026
d3b1f7b
fix: rolldownConfig.output is optional
pi0 Feb 10, 2026
eb8d7f7
types: mark output config as non nullable
pi0 Feb 12, 2026
af0c6ca
refactor: improve output chunk names (#4027)
pi0 Feb 12, 2026
ae02f3b
fix: avoid adding extra additional export conditions (#4029)
pi0 Feb 12, 2026
09d6aa6
fix: also avoid inferring `bun` and `deno` from runtime
pi0 Feb 12, 2026
0f4c665
fix: preserve sourcemap mappings for chunks containing user code (#4031)
logaretm Feb 12, 2026
7857f44
fix: sync routes after scan handlers (#4033)
RihanArfan Feb 13, 2026
f663e76
presets(vercel): integrate with scheduled tasks (#4030)
RihanArfan Feb 13, 2026
bed0415
chore(deps): update all non-major dependencies (#4035)
renovate[bot] Feb 17, 2026
b28fa21
chore: update deps
pi0 Feb 17, 2026
50b3bc5
fix(prerender): skip writing routes with `..` or outside of public dir
pi0 Feb 17, 2026
f961775
presets(vercel): add framework info to build output config (#4032)
RihanArfan Feb 18, 2026
906dcd1
docs
pi0 Feb 18, 2026
254ff34
feat(tasks): expose req and waitUntil in context (#4037)
RihanArfan Feb 18, 2026
118e77a
refactor: use `proxyFetch` from httpxy
pi0 Feb 18, 2026
d832f3c
refactor: update worker addr types
pi0 Feb 18, 2026
d1152e5
chore: remove old test
pi0 Feb 18, 2026
5fcae46
chore: update deps
pi0 Feb 18, 2026
5fc63f0
chore: force resolve rolldown to rc5
pi0 Feb 18, 2026
d06b90b
refactor: use isolated declaration for runtime
pi0 Feb 18, 2026
bbf2808
refactor: use new httpxy features
pi0 Feb 18, 2026
775e512
feat: `nitro preview` (#4024)
pi0 Feb 18, 2026
4df7aab
feat: `nitro deploy` command (#4042)
pi0 Feb 19, 2026
1daa177
fix(vite): don't send browser full-reload for ssr-only changes (#4034)
schiller-manuel Feb 23, 2026
c0b4642
presets(cloudflare): integrate with scheduled tasks (#4046)
RihanArfan Feb 23, 2026
b954d0a
chore(deps): update all non-major dependencies (#4054)
renovate[bot] Feb 25, 2026
5ccf672
refactor(config): improve builder auto-detection logic (#4058)
pi0 Feb 26, 2026
bfbb207
feat(vite): auto-detect client entry (#4059)
RihanArfan Feb 27, 2026
02ff766
chore: update deps
pi0 Mar 9, 2026
7a5d536
fix: escape scanned route url param names
pi0 Mar 9, 2026
13fde6a
test: update bundle size
pi0 Mar 9, 2026
ae97355
chore: bump nf3
pi0 Mar 9, 2026
0da93bd
fix(vite): avoid adding duplicate nitro plugins when using `nitro build`
pi0 Mar 9, 2026
90329a2
presets: add `zephyr` (#4038)
pi0 Mar 9, 2026
a1c45b7
chore(deps): update all non-major dependencies (#4065)
renovate[bot] Mar 9, 2026
c388aab
fix zephyr build
pi0 Mar 9, 2026
5b4d5d8
build: bundle docs as skill + `nitro docs` (#4084)
pi0 Mar 9, 2026
66a0a97
fix test
pi0 Mar 9, 2026
a2ee33b
Revert "feat(vite): auto-detect client entry (#4059)"
pi0 Mar 9, 2026
a1821d5
fix: make error handlers consistent with h3 (#4055)
pi0 Mar 9, 2026
49093eb
refactor: migrate to unjs/ocache (#4087)
pi0 Mar 9, 2026
1d8910b
chore: update deps
pi0 Mar 10, 2026
d95f2ae
feat: use unjs/env-runner (#4088)
pi0 Mar 10, 2026
e7a2080
chore(deps): update all non-major dependencies (#4089)
renovate[bot] Mar 10, 2026
e937ffb
feat(vite): respect vite `mode` for env loading (#4082)
kricsleo Mar 10, 2026
752f942
fix(static): only append Vary: Accept-Encoding after a static asset m…
schiller-manuel Mar 10, 2026
9d6ad0a
fix(vite): run scheduled tasks during vite dev (#4076)
RihanArfan Mar 10, 2026
201889a
fix(config): apply $production/$development layers when NODE_ENV is u…
jlgrimes Mar 10, 2026
644b175
feat(route-rules): basic auth (#4049)
RihanArfan Mar 10, 2026
fc42955
chore: update agents notes
pi0 Mar 10, 2026
31dd14c
feat(vite): support preview (#4090)
pi0 Mar 10, 2026
fd86f89
docs: add Zephyr Cloud deploy docs (#4092)
Nsttt Mar 10, 2026
1ea7ec1
docs: prepare for v3 beta (#4091)
pi0 Mar 10, 2026
9bb6453
chore: apply automated updates
autofix-ci[bot] Mar 10, 2026
62e7683
chore: update docs link
pi0 Mar 10, 2026
f6337f7
rm unused import
pi0 Mar 10, 2026
5ea3e15
docs: fix link to v2
pi0 Mar 10, 2026
26f54ec
chore: update agents.md
pi0 Mar 11, 2026
8c862f8
chore: add copilor repo files
pi0 Mar 11, 2026
3888905
refactor(vite): use `sec-websocket-protocol` to detect Vite WS connec…
Copilot Mar 11, 2026
ae6759a
docs(cloudflare): fix env bindings access pattern for Nitro v3 (break…
ruan-cat Mar 11, 2026
80cd914
chore: try new versioning (`[major]..[date]`) (#4099)
pi0 Mar 11, 2026
e1f0057
feat: export http utils from `nitro` (#4097)
pi0 Mar 11, 2026
9d7ca6d
test (zephyr): properly mock `importDep` (#4100)
Copilot Mar 11, 2026
a77a5c4
chore: improve bump script
pi0 Mar 11, 2026
3cf095a
chore: use release script
pi0 Mar 11, 2026
47817a2
trigger ci
pi0 Mar 11, 2026
c23e9c2
ci: set environment for deploy-nightly
pi0 Mar 11, 2026
793b759
chore: update release scripts
pi0 Mar 11, 2026
e5a24d5
chore: apply automated updates
autofix-ci[bot] Mar 11, 2026
3ab8713
improve local script safety
pi0 Mar 11, 2026
fc8645d
chore: updatte release script
pi0 Mar 11, 2026
a191078
fix release script
pi0 Mar 11, 2026
6880a7f
set version
pi0 Mar 11, 2026
bb2df26
lint
pi0 Mar 11, 2026
28d4fb1
disable flaky test
pi0 Mar 11, 2026
76a41a7
update release script tests
pi0 Mar 11, 2026
1d05f55
ci: add missing --tag
pi0 Mar 11, 2026
47c85b5
v3.0.260311-beta
pi0 Mar 11, 2026
3f44033
update release script
pi0 Mar 11, 2026
12d58f1
fix(cloudflare-dev): match getPlatformProxy dev behaviour with produc…
RihanArfan Mar 11, 2026
0f366e5
docs: v3 beta (#4101)
pi0 Mar 11, 2026
377e86e
fix issues in blog post
pi0 Mar 11, 2026
ba5147a
chore: remove unused `fs-extra` dev dependency (#4104)
gameroman Mar 12, 2026
5f77858
chore: update deps
pi0 Mar 14, 2026
5247276
refactor: improve tsconfig preset
pi0 Mar 15, 2026
1046364
chore: apply automated updates
autofix-ci[bot] Mar 15, 2026
50c3d5f
fix: use `rolldown/utils` and disable additional tsconfig parsing (#4…
danielroe Mar 15, 2026
c31268c
refactor: remove `experimental.tsconfigPaths` (#4112)
pi0 Mar 15, 2026
22d821d
chore: fix typo in mono-jsx example (#4117)
KTibow Mar 16, 2026
102191a
fix(route-meta): unique handlers by hash + method + route (#4119)
OskarLebuda Mar 16, 2026
e14976f
fix(route-meta): deduplicate routing-meta imports by _importHash only…
OskarLebuda Mar 16, 2026
5d51b7f
docs: correct routing example code (#3937)
kricsleo Mar 17, 2026
9c2e244
docs: clarify overlapping dynamic route parameters limitation
ramanverse Mar 19, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
157 changes: 157 additions & 0 deletions .agents/architecture.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,157 @@
# Nitro Architecture Deep Dive

## Core Instance (`src/nitro.ts`)

`createNitro(config, opts)` creates the main context with:
- `options: NitroOptions` — Resolved configuration
- `hooks: Hookable<NitroHooks>` — Build lifecycle hooks
- `vfs: Map<string, { render }>` — Virtual file system
- `routing: { routes, routeRules, globalMiddleware, routedMiddleware }`
- `scannedHandlers: NitroEventHandler[]`
- `unimport?: Unimport` — Auto-imports (optional)
- `logger: ConsolaInstance`
- `updateConfig(config)` — Hot-reload config
- `close()` — Cleanup

**Setup flow:**
1. Load options via `loadOptions()`
2. Install modules via `installModules()`
3. Init routing via `initNitroRouting()`
4. Scan handlers/plugins/tasks via `scanAndSyncOptions()`
5. Prepare unimport for auto-imports
6. Setup hooks

## Entry Points

- `src/builder.ts` — Main public API: `createNitro()`, `build()`, `createDevServer()`, `prerender()`, `copyPublicAssets()`, `prepare()`, `writeTypes()`, `runTask()`, `listTasks()`
- `src/vite.ts` — Vite plugin export from `src/build/vite/plugin.ts`

## Build System (`src/build/`)

**Builder dispatch** (`build/build.ts`): delegates to `rollup`, `rolldown`, or `vite` based on `nitro.options.builder`.

**Builder selection** (resolved in `config/resolvers/builder.ts`):
- Check `NITRO_BUILDER` / `NITRO_VITE_BUILDER` env vars
- Auto-detect available packages
- Fallback: rolldown → vite → rollup

**Base config** (`build/config.ts`):
- Extensions: `.ts`, `.mjs`, `.js`, `.json`, `.node`, `.tsx`, `.jsx`
- Import.meta replacements (`import.meta.dev`, `import.meta.preset`, etc.)
- Unenv aliases for polyfills
- External dependency patterns

**Plugins** (`build/plugins.ts`):
1. Virtual modules — renders from `build/virtual/`
2. Auto imports — Unimport plugin
3. WASM loader — unwasm
4. Server main injection — `globalThis.__server_main__`
5. Raw imports — `?raw` suffix
6. Route meta — OpenAPI metadata
7. Replace plugin — variable substitution
8. Externals plugin — Node.js native resolution
9. Sourcemap minify (optional)

**Virtual modules** (`build/virtual/`, 14 templates):
All prefixed `#nitro/virtual/<name>`:
- `routing.ts` — Compiled router matcher
- `plugins.ts` — Plugin registry
- `error-handler.ts` — Error handler
- `public-assets.ts` — Public asset metadata
- `server-assets.ts` — Server asset metadata
- `runtime-config.ts` — Runtime config object
- `database.ts` — Database setup
- `storage.ts` — Storage backends
- `tasks.ts` — Task registry
- `polyfills.ts` — Env polyfills
- `feature-flags.ts` — Feature detection
- `routing-meta.ts` — Route metadata (OpenAPI)
- `renderer-template.ts` — SSR renderer
- `_all.ts` — Aggregator

## Configuration System (`src/config/`)

**Loader** (`config/loader.ts`): `loadOptions(config, opts)`
1. Merge with defaults (`NitroDefaults`)
2. Load c12 config files (`nitro.config.ts`, `package.json.nitro`, etc.)
3. Resolve preset
4. Run config resolvers sequentially

**Resolvers** (`config/resolvers/`):
`compatibility`, `tsconfig`, `paths`, `imports`, `route-rules`, `database`, `export-conditions`, `runtime-config`, `open-api`, `url`, `assets`, `storage`, `error`, `unenv`, `builder`

**Defaults** (`config/defaults.ts`): All NitroConfig defaults.

## Runtime (`src/runtime/`)

**Internal** (`runtime/internal/`):
- `app.ts` — NitroApp creation, H3 app setup
- `cache.ts` — Response caching
- `context.ts` — Async context
- `route-rules.ts` — Route rule middleware (headers, redirect, proxy, cache, cors)
- `static.ts` — Static file serving
- `task.ts` — Task execution
- `plugin.ts` — Plugin helpers
- `runtime-config.ts` — Config getter

**Public exports**: `runtime/app.ts` (`defineConfig()`), `runtime/nitro.ts` (`serverFetch()`), `runtime/cache.ts`, `runtime/task.ts`, `runtime/storage.ts`, etc.

## Dev Server (`src/dev/`)

- `dev/server.ts` — `NitroDevServer`: Worker management via `env-runner`, restart on failure (max 3 retries), WebSocket support, VFS debug endpoint (`/_vfs/**`)
- `dev/app.ts` — `NitroDevApp`: H3 app with error handling, static serving with compression, dev proxy

## Prerender (`src/prerender/`)

- `prerender/prerender.ts` — Main flow: parse routes → build prerenderer (preset: `nitro-prerender`) → execute in parallel → link crawling → write to disk → compress
- `prerender/utils.ts` — `extractLinks()`, `matchesIgnorePattern()`, `formatPrerenderRoute()`

## Routing & Scanning (`src/routing.ts`, `src/scan.ts`)

**Scanning**: Discovers routes, middleware, plugins, tasks, modules from filesystem.

Route file conventions:
- `routes/index.ts` → `GET /`
- `routes/users/[id].ts` → `GET /users/:id`
- `routes/users/[...slug].ts` → `GET /users/**:slug`
- `api/users.post.ts` → `POST /api/users`
- `.dev`/`.prod`/`.prerender` suffixes for environment filtering

**Router** (`Router` class): Based on `rou3`, compiles to optimized string matcher, supports method routing + env conditions.

## Presets (`src/presets/`)

31 presets. Structure per preset:
```
presets/<name>/
├── preset.ts # defineNitroPreset()
├── runtime/ # Runtime entry (bundled)
├── types.ts # Types (optional)
├── utils.ts # Build-time utils (optional)
└── unenv/ # Env overrides (optional)
```

Key presets: `standard`, `node` (server/middleware/cluster), `cloudflare` (pages/workers), `vercel`, `netlify`, `aws-lambda`, `deno`, `firebase`, `azure`, `bun`, `winterjs`

Resolution: `presets/_resolve.ts` handles aliases, dev/prod, compat dates, static hosting.

## CLI (`src/cli/`)

Uses `citty` with lazy-loaded commands: `dev`, `build`, `deploy`, `preview`, `prepare`, `task`, `docs`.

## Key Libraries

| Library | Purpose |
|---------|---------|
| `h3` | HTTP framework |
| `rou3` | Route matching |
| `c12` | Config loading |
| `citty` | CLI framework |
| `hookable` | Hook system |
| `unimport` | Auto-imports |
| `unstorage` | Storage abstraction |
| `unenv` | Runtime polyfills |
| `defu` | Config merging |
| `pathe` | Path operations |
| `consola` | Logging |
| `env-runner` | Worker management |
Loading