@depup/nitro 3.0.260311-beta-depup.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (370) hide show
  1. package/LICENSE +27 -0
  2. package/README.md +32 -0
  3. package/changes.json +14 -0
  4. package/dist/THIRD-PARTY-LICENSES.md +1646 -0
  5. package/dist/_build/common.mjs +29361 -0
  6. package/dist/_build/rolldown.mjs +173 -0
  7. package/dist/_build/rollup.mjs +194 -0
  8. package/dist/_build/vite.build.mjs +18 -0
  9. package/dist/_chunks/nitro.mjs +1159 -0
  10. package/dist/_chunks/nitro2.mjs +102 -0
  11. package/dist/_chunks/nitro3.mjs +129 -0
  12. package/dist/_chunks/utils.mjs +272 -0
  13. package/dist/_common.mjs +35 -0
  14. package/dist/_dev.d.mts +12 -0
  15. package/dist/_dev.mjs +519 -0
  16. package/dist/_libs/_.mjs +3 -0
  17. package/dist/_libs/_2.mjs +2 -0
  18. package/dist/_libs/_3.mjs +3 -0
  19. package/dist/_libs/_4.mjs +2 -0
  20. package/dist/_libs/_5.mjs +3 -0
  21. package/dist/_libs/_6.mjs +4 -0
  22. package/dist/_libs/_7.mjs +5 -0
  23. package/dist/_libs/c12+rc9.mjs +812 -0
  24. package/dist/_libs/c12+readdirp+chokidar.d.mts +230 -0
  25. package/dist/_libs/citty.mjs +361 -0
  26. package/dist/_libs/commondir+is-reference.mjs +1311 -0
  27. package/dist/_libs/compatx.d.mts +47 -0
  28. package/dist/_libs/compatx.mjs +45 -0
  29. package/dist/_libs/esbuild.d.mts +20 -0
  30. package/dist/_libs/escape-string-regexp.mjs +7 -0
  31. package/dist/_libs/estree+pluginutils.d.mts +241 -0
  32. package/dist/_libs/estree-walker.mjs +184 -0
  33. package/dist/_libs/exsolve.d.mts +1 -0
  34. package/dist/_libs/hasown+resolve+deepmerge.mjs +1949 -0
  35. package/dist/_libs/httpxy.d.mts +82 -0
  36. package/dist/_libs/httpxy.mjs +671 -0
  37. package/dist/_libs/js-tokens.d.mts +1 -0
  38. package/dist/_libs/klona.mjs +37 -0
  39. package/dist/_libs/magic-string.d.mts +220 -0
  40. package/dist/_libs/mlly.d.mts +57 -0
  41. package/dist/_libs/nypm+tinyexec.mjs +845 -0
  42. package/dist/_libs/perfect-debounce.mjs +88 -0
  43. package/dist/_libs/pkg-types.d.mts +23 -0
  44. package/dist/_libs/plugin-alias.mjs +64 -0
  45. package/dist/_libs/plugin-inject.mjs +131 -0
  46. package/dist/_libs/plugin-json.mjs +34 -0
  47. package/dist/_libs/pluginutils.mjs +646 -0
  48. package/dist/_libs/readdirp+chokidar.mjs +1606 -0
  49. package/dist/_libs/remapping.mjs +115 -0
  50. package/dist/_libs/resolve-uri+gen-mapping.mjs +442 -0
  51. package/dist/_libs/rou3.d.mts +44 -0
  52. package/dist/_libs/rou3.mjs +496 -0
  53. package/dist/_libs/std-env.d.mts +12 -0
  54. package/dist/_libs/strip-literal.d.mts +1 -0
  55. package/dist/_libs/tsconfck.mjs +813 -0
  56. package/dist/_libs/ultrahtml.mjs +127 -0
  57. package/dist/_libs/unimport+unplugin.mjs +1684 -0
  58. package/dist/_libs/unplugin+unimport.d.mts +423 -0
  59. package/dist/_libs/unwasm.d.mts +29 -0
  60. package/dist/_presets.mjs +1759 -0
  61. package/dist/builder.d.mts +64 -0
  62. package/dist/builder.mjs +15 -0
  63. package/dist/cli/_chunks/build.mjs +47 -0
  64. package/dist/cli/_chunks/common.mjs +14 -0
  65. package/dist/cli/_chunks/deploy.mjs +40 -0
  66. package/dist/cli/_chunks/dev.mjs +62 -0
  67. package/dist/cli/_chunks/docs.mjs +30 -0
  68. package/dist/cli/_chunks/list.mjs +25 -0
  69. package/dist/cli/_chunks/prepare.mjs +17 -0
  70. package/dist/cli/_chunks/preview.mjs +51 -0
  71. package/dist/cli/_chunks/run.mjs +53 -0
  72. package/dist/cli/_chunks/task.mjs +14 -0
  73. package/dist/cli/index.d.mts +1 -0
  74. package/dist/cli/index.mjs +22 -0
  75. package/dist/node_modules/@poppinss/colors/build/index.js +139 -0
  76. package/dist/node_modules/@poppinss/colors/package.json +118 -0
  77. package/dist/node_modules/@poppinss/dumper/build/chunk-26HALFTP.js +602 -0
  78. package/dist/node_modules/@poppinss/dumper/build/formatters/console/main.js +441 -0
  79. package/dist/node_modules/@poppinss/dumper/build/formatters/html/main.js +725 -0
  80. package/dist/node_modules/@poppinss/dumper/package.json +122 -0
  81. package/dist/node_modules/@poppinss/exception/build/index.js +44 -0
  82. package/dist/node_modules/@poppinss/exception/package.json +109 -0
  83. package/dist/node_modules/@sindresorhus/is/distribution/index.js +1354 -0
  84. package/dist/node_modules/@sindresorhus/is/distribution/utilities.js +3 -0
  85. package/dist/node_modules/@sindresorhus/is/package.json +81 -0
  86. package/dist/node_modules/@speed-highlight/core/dist/index.js +4 -0
  87. package/dist/node_modules/@speed-highlight/core/dist/terminal.js +2 -0
  88. package/dist/node_modules/@speed-highlight/core/package.json +94 -0
  89. package/dist/node_modules/cookie-es/dist/index.mjs +262 -0
  90. package/dist/node_modules/cookie-es/package.json +37 -0
  91. package/dist/node_modules/croner/dist/croner.js +1 -0
  92. package/dist/node_modules/croner/package.json +73 -0
  93. package/dist/node_modules/defu/dist/defu.mjs +69 -0
  94. package/dist/node_modules/defu/package.json +43 -0
  95. package/dist/node_modules/destr/dist/index.mjs +72 -0
  96. package/dist/node_modules/destr/package.json +47 -0
  97. package/dist/node_modules/error-stack-parser-es/dist/index.mjs +38 -0
  98. package/dist/node_modules/error-stack-parser-es/dist/lite.mjs +167 -0
  99. package/dist/node_modules/error-stack-parser-es/package.json +83 -0
  100. package/dist/node_modules/get-port-please/dist/index.mjs +430 -0
  101. package/dist/node_modules/get-port-please/package.json +39 -0
  102. package/dist/node_modules/kleur/index.mjs +110 -0
  103. package/dist/node_modules/kleur/package.json +51 -0
  104. package/dist/node_modules/rendu/dist/index.mjs +380 -0
  105. package/dist/node_modules/rendu/package.json +47 -0
  106. package/dist/node_modules/scule/dist/index.mjs +80 -0
  107. package/dist/node_modules/scule/package.json +43 -0
  108. package/dist/node_modules/source-map/lib/array-set.js +100 -0
  109. package/dist/node_modules/source-map/lib/base64-vlq.js +94 -0
  110. package/dist/node_modules/source-map/lib/base64.js +19 -0
  111. package/dist/node_modules/source-map/lib/binary-search.js +113 -0
  112. package/dist/node_modules/source-map/lib/mapping-list.js +83 -0
  113. package/dist/node_modules/source-map/lib/mappings.wasm +0 -0
  114. package/dist/node_modules/source-map/lib/read-wasm.js +27 -0
  115. package/dist/node_modules/source-map/lib/source-map-consumer.js +1081 -0
  116. package/dist/node_modules/source-map/lib/source-map-generator.js +439 -0
  117. package/dist/node_modules/source-map/lib/source-node.js +430 -0
  118. package/dist/node_modules/source-map/lib/url.js +13 -0
  119. package/dist/node_modules/source-map/lib/util.js +444 -0
  120. package/dist/node_modules/source-map/lib/wasm.js +138 -0
  121. package/dist/node_modules/source-map/package.json +79 -0
  122. package/dist/node_modules/source-map/source-map.js +10 -0
  123. package/dist/node_modules/supports-color/index.js +202 -0
  124. package/dist/node_modules/supports-color/package.json +64 -0
  125. package/dist/node_modules/ufo/dist/index.mjs +645 -0
  126. package/dist/node_modules/ufo/package.json +48 -0
  127. package/dist/node_modules/unctx/dist/index.mjs +131 -0
  128. package/dist/node_modules/unctx/package.json +67 -0
  129. package/dist/node_modules/youch/build/helpers-B9BQYaS6.js +23 -0
  130. package/dist/node_modules/youch/build/index.js +212 -0
  131. package/dist/node_modules/youch/build/public/error_cause/style.css +5 -0
  132. package/dist/node_modules/youch/build/public/error_info/script.js +13 -0
  133. package/dist/node_modules/youch/build/public/error_info/style.css +145 -0
  134. package/dist/node_modules/youch/build/public/error_metadata/style.css +3 -0
  135. package/dist/node_modules/youch/build/public/error_stack/script.js +72 -0
  136. package/dist/node_modules/youch/build/public/error_stack/style.css +219 -0
  137. package/dist/node_modules/youch/build/public/error_stack_source/style.css +123 -0
  138. package/dist/node_modules/youch/build/public/header/script.js +14 -0
  139. package/dist/node_modules/youch/build/public/header/style.css +56 -0
  140. package/dist/node_modules/youch/build/public/layout/script.js +12 -0
  141. package/dist/node_modules/youch/build/public/layout/style.css +435 -0
  142. package/dist/node_modules/youch/build/public_dir-C5bujZKB.js +25 -0
  143. package/dist/node_modules/youch/build/src/templates/error_cause/main.js +44 -0
  144. package/dist/node_modules/youch/build/src/templates/error_info/main.js +72 -0
  145. package/dist/node_modules/youch/build/src/templates/error_metadata/main.js +65 -0
  146. package/dist/node_modules/youch/build/src/templates/error_stack/main.js +152 -0
  147. package/dist/node_modules/youch/build/src/templates/error_stack_source/main.js +46 -0
  148. package/dist/node_modules/youch/build/src/templates/header/main.js +24 -0
  149. package/dist/node_modules/youch/build/src/templates/layout/main.js +27 -0
  150. package/dist/node_modules/youch/package.json +135 -0
  151. package/dist/node_modules/youch-core/build/index.js +316 -0
  152. package/dist/node_modules/youch-core/package.json +124 -0
  153. package/dist/presets/_nitro/runtime/nitro-dev.mjs +20 -0
  154. package/dist/presets/_nitro/runtime/nitro-prerenderer.mjs +15 -0
  155. package/dist/presets/_nitro/runtime/service-worker.mjs +23 -0
  156. package/dist/presets/aws-amplify/runtime/aws-amplify.mjs +14 -0
  157. package/dist/presets/aws-lambda/runtime/_utils.mjs +116 -0
  158. package/dist/presets/aws-lambda/runtime/aws-lambda-streaming.mjs +31 -0
  159. package/dist/presets/aws-lambda/runtime/aws-lambda.mjs +13 -0
  160. package/dist/presets/azure/runtime/_utils.mjs +50 -0
  161. package/dist/presets/azure/runtime/azure-swa.mjs +30 -0
  162. package/dist/presets/bun/runtime/bun.mjs +40 -0
  163. package/dist/presets/cloudflare/runtime/_module-handler.mjs +87 -0
  164. package/dist/presets/cloudflare/runtime/cloudflare-durable.mjs +72 -0
  165. package/dist/presets/cloudflare/runtime/cloudflare-module.mjs +17 -0
  166. package/dist/presets/cloudflare/runtime/cloudflare-pages.mjs +39 -0
  167. package/dist/presets/cloudflare/runtime/plugin.dev.mjs +96 -0
  168. package/dist/presets/cloudflare/runtime/shims/workers.dev.mjs +27 -0
  169. package/dist/presets/deno/runtime/deno-deploy.mjs +19 -0
  170. package/dist/presets/deno/runtime/deno-server.mjs +39 -0
  171. package/dist/presets/netlify/runtime/netlify-edge.mjs +20 -0
  172. package/dist/presets/netlify/runtime/netlify.mjs +20 -0
  173. package/dist/presets/node/runtime/node-cluster.mjs +54 -0
  174. package/dist/presets/node/runtime/node-middleware.mjs +14 -0
  175. package/dist/presets/node/runtime/node-server.mjs +47 -0
  176. package/dist/presets/standard/runtime/server.mjs +4 -0
  177. package/dist/presets/stormkit/runtime/stormkit.mjs +27 -0
  178. package/dist/presets/vercel/runtime/cron-handler.mjs +25 -0
  179. package/dist/presets/vercel/runtime/isr.mjs +19 -0
  180. package/dist/presets/vercel/runtime/vercel.node.mjs +24 -0
  181. package/dist/presets/vercel/runtime/vercel.web.mjs +23 -0
  182. package/dist/presets/winterjs/runtime/winterjs.mjs +91 -0
  183. package/dist/presets/zeabur/runtime/zeabur.mjs +4 -0
  184. package/dist/presets/zephyr/runtime/server.mjs +3 -0
  185. package/dist/runtime/app.d.mts +1 -0
  186. package/dist/runtime/app.mjs +1 -0
  187. package/dist/runtime/cache.d.mts +1 -0
  188. package/dist/runtime/cache.mjs +1 -0
  189. package/dist/runtime/config.d.mts +3 -0
  190. package/dist/runtime/config.mjs +4 -0
  191. package/dist/runtime/context.d.mts +1 -0
  192. package/dist/runtime/context.mjs +1 -0
  193. package/dist/runtime/database.d.mts +1 -0
  194. package/dist/runtime/database.mjs +1 -0
  195. package/dist/runtime/internal/app.d.mts +16 -0
  196. package/dist/runtime/internal/app.mjs +208 -0
  197. package/dist/runtime/internal/cache.d.mts +7 -0
  198. package/dist/runtime/internal/cache.mjs +41 -0
  199. package/dist/runtime/internal/context.d.mts +14 -0
  200. package/dist/runtime/internal/context.mjs +24 -0
  201. package/dist/runtime/internal/database.d.mts +2 -0
  202. package/dist/runtime/internal/database.mjs +12 -0
  203. package/dist/runtime/internal/empty.mjs +0 -0
  204. package/dist/runtime/internal/error/dev.d.mts +10 -0
  205. package/dist/runtime/internal/error/dev.mjs +121 -0
  206. package/dist/runtime/internal/error/hooks.d.mts +1 -0
  207. package/dist/runtime/internal/error/hooks.mjs +9 -0
  208. package/dist/runtime/internal/error/prod.d.mts +6 -0
  209. package/dist/runtime/internal/error/prod.mjs +40 -0
  210. package/dist/runtime/internal/error/utils.d.mts +8 -0
  211. package/dist/runtime/internal/error/utils.mjs +3 -0
  212. package/dist/runtime/internal/meta.d.mts +2 -0
  213. package/dist/runtime/internal/meta.mjs +3 -0
  214. package/dist/runtime/internal/plugin.d.mts +3 -0
  215. package/dist/runtime/internal/plugin.mjs +4 -0
  216. package/dist/runtime/internal/route-rules.d.mts +9 -0
  217. package/dist/runtime/internal/route-rules.mjs +72 -0
  218. package/dist/runtime/internal/routes/dev-tasks.d.mts +3 -0
  219. package/dist/runtime/internal/routes/dev-tasks.mjs +25 -0
  220. package/dist/runtime/internal/routes/openapi.d.mts +3 -0
  221. package/dist/runtime/internal/routes/openapi.mjs +94 -0
  222. package/dist/runtime/internal/routes/renderer-template.d.mts +2 -0
  223. package/dist/runtime/internal/routes/renderer-template.dev.d.mts +3 -0
  224. package/dist/runtime/internal/routes/renderer-template.dev.mjs +19 -0
  225. package/dist/runtime/internal/routes/renderer-template.mjs +4 -0
  226. package/dist/runtime/internal/routes/scalar.d.mts +3 -0
  227. package/dist/runtime/internal/routes/scalar.mjs +193 -0
  228. package/dist/runtime/internal/routes/swagger.d.mts +3 -0
  229. package/dist/runtime/internal/routes/swagger.mjs +42 -0
  230. package/dist/runtime/internal/runtime-config.d.mts +9 -0
  231. package/dist/runtime/internal/runtime-config.mjs +54 -0
  232. package/dist/runtime/internal/static.d.mts +3 -0
  233. package/dist/runtime/internal/static.mjs +67 -0
  234. package/dist/runtime/internal/storage.d.mts +2 -0
  235. package/dist/runtime/internal/storage.mjs +6 -0
  236. package/dist/runtime/internal/task.d.mts +19 -0
  237. package/dist/runtime/internal/task.mjs +69 -0
  238. package/dist/runtime/internal/vite/dev-entry.mjs +18 -0
  239. package/dist/runtime/internal/vite/dev-worker.mjs +264 -0
  240. package/dist/runtime/internal/vite/ssr-renderer.mjs +6 -0
  241. package/dist/runtime/meta.d.mts +5 -0
  242. package/dist/runtime/meta.mjs +27 -0
  243. package/dist/runtime/nitro.d.mts +11 -0
  244. package/dist/runtime/nitro.mjs +34 -0
  245. package/dist/runtime/runtime-config.d.mts +1 -0
  246. package/dist/runtime/runtime-config.mjs +1 -0
  247. package/dist/runtime/storage.d.mts +1 -0
  248. package/dist/runtime/storage.mjs +1 -0
  249. package/dist/runtime/task.d.mts +1 -0
  250. package/dist/runtime/task.mjs +1 -0
  251. package/dist/runtime/virtual/_runtime_warn.d.mts +1 -0
  252. package/dist/runtime/virtual/_runtime_warn.mjs +5 -0
  253. package/dist/runtime/virtual/database.d.mts +8 -0
  254. package/dist/runtime/virtual/database.mjs +2 -0
  255. package/dist/runtime/virtual/error-handler.d.mts +6 -0
  256. package/dist/runtime/virtual/error-handler.mjs +9 -0
  257. package/dist/runtime/virtual/feature-flags.d.mts +7 -0
  258. package/dist/runtime/virtual/feature-flags.mjs +7 -0
  259. package/dist/runtime/virtual/plugins.d.mts +3 -0
  260. package/dist/runtime/virtual/plugins.mjs +2 -0
  261. package/dist/runtime/virtual/polyfills.d.mts +3 -0
  262. package/dist/runtime/virtual/polyfills.mjs +2 -0
  263. package/dist/runtime/virtual/public-assets.d.mts +9 -0
  264. package/dist/runtime/virtual/public-assets.mjs +8 -0
  265. package/dist/runtime/virtual/renderer-template.d.mts +4 -0
  266. package/dist/runtime/virtual/renderer-template.mjs +7 -0
  267. package/dist/runtime/virtual/routing-meta.d.mts +7 -0
  268. package/dist/runtime/virtual/routing-meta.mjs +2 -0
  269. package/dist/runtime/virtual/routing.d.mts +8 -0
  270. package/dist/runtime/virtual/routing.mjs +11 -0
  271. package/dist/runtime/virtual/runtime-config.d.mts +3 -0
  272. package/dist/runtime/virtual/runtime-config.mjs +5 -0
  273. package/dist/runtime/virtual/server-assets.d.mts +7 -0
  274. package/dist/runtime/virtual/server-assets.mjs +12 -0
  275. package/dist/runtime/virtual/storage.d.mts +3 -0
  276. package/dist/runtime/virtual/storage.mjs +5 -0
  277. package/dist/runtime/virtual/tasks.d.mts +10 -0
  278. package/dist/runtime/virtual/tasks.mjs +3 -0
  279. package/dist/runtime/vite.d.mts +8 -0
  280. package/dist/runtime/vite.mjs +9 -0
  281. package/dist/types/index.d.mts +3010 -0
  282. package/dist/types/index.mjs +1 -0
  283. package/dist/vite.d.mts +52 -0
  284. package/dist/vite.mjs +740 -0
  285. package/lib/h3.d.mts +1 -0
  286. package/lib/h3.mjs +1 -0
  287. package/lib/tsconfig.json +27 -0
  288. package/lib/vite.types.d.mts +26 -0
  289. package/lib/vite.types.mjs +2 -0
  290. package/package.json +256 -0
  291. package/skills/nitro/SKILL.md +10 -0
  292. package/skills/nitro/docs/TOC.md +83 -0
  293. package/skills/nitro/docs/_navigation.json +679 -0
  294. package/skills/nitro/docs/config/index.md +1147 -0
  295. package/skills/nitro/docs/deploy/index.md +64 -0
  296. package/skills/nitro/docs/deploy/providers/alwaysdata.md +50 -0
  297. package/skills/nitro/docs/deploy/providers/aws-amplify.md +81 -0
  298. package/skills/nitro/docs/deploy/providers/aws.md +47 -0
  299. package/skills/nitro/docs/deploy/providers/azure.md +72 -0
  300. package/skills/nitro/docs/deploy/providers/cleavr.md +33 -0
  301. package/skills/nitro/docs/deploy/providers/cloudflare.md +375 -0
  302. package/skills/nitro/docs/deploy/providers/deno-deploy.md +66 -0
  303. package/skills/nitro/docs/deploy/providers/digitalocean.md +46 -0
  304. package/skills/nitro/docs/deploy/providers/firebase.md +32 -0
  305. package/skills/nitro/docs/deploy/providers/flightcontrol.md +67 -0
  306. package/skills/nitro/docs/deploy/providers/genezio.md +67 -0
  307. package/skills/nitro/docs/deploy/providers/github-pages.md +68 -0
  308. package/skills/nitro/docs/deploy/providers/gitlab-pages.md +37 -0
  309. package/skills/nitro/docs/deploy/providers/heroku.md +84 -0
  310. package/skills/nitro/docs/deploy/providers/iis.md +38 -0
  311. package/skills/nitro/docs/deploy/providers/koyeb.md +109 -0
  312. package/skills/nitro/docs/deploy/providers/netlify.md +47 -0
  313. package/skills/nitro/docs/deploy/providers/platform-sh.md +37 -0
  314. package/skills/nitro/docs/deploy/providers/render.md +37 -0
  315. package/skills/nitro/docs/deploy/providers/stormkit.md +24 -0
  316. package/skills/nitro/docs/deploy/providers/vercel.md +179 -0
  317. package/skills/nitro/docs/deploy/providers/zeabur.md +19 -0
  318. package/skills/nitro/docs/deploy/providers/zephyr.md +99 -0
  319. package/skills/nitro/docs/deploy/providers/zerops.md +102 -0
  320. package/skills/nitro/docs/deploy/runtimes/bun.md +15 -0
  321. package/skills/nitro/docs/deploy/runtimes/deno.md +19 -0
  322. package/skills/nitro/docs/deploy/runtimes/node.md +63 -0
  323. package/skills/nitro/docs/docs/assets.md +166 -0
  324. package/skills/nitro/docs/docs/cache.md +408 -0
  325. package/skills/nitro/docs/docs/configuration.md +256 -0
  326. package/skills/nitro/docs/docs/database.md +185 -0
  327. package/skills/nitro/docs/docs/index.md +56 -0
  328. package/skills/nitro/docs/docs/lifecycle.md +204 -0
  329. package/skills/nitro/docs/docs/migration.md +215 -0
  330. package/skills/nitro/docs/docs/nightly.md +31 -0
  331. package/skills/nitro/docs/docs/plugins.md +164 -0
  332. package/skills/nitro/docs/docs/quick-start.md +110 -0
  333. package/skills/nitro/docs/docs/renderer.md +322 -0
  334. package/skills/nitro/docs/docs/routing.md +711 -0
  335. package/skills/nitro/docs/docs/server-entry.md +239 -0
  336. package/skills/nitro/docs/docs/storage.md +261 -0
  337. package/skills/nitro/docs/docs/tasks.md +277 -0
  338. package/skills/nitro/docs/examples/api-routes.md +145 -0
  339. package/skills/nitro/docs/examples/auto-imports.md +93 -0
  340. package/skills/nitro/docs/examples/cached-handler.md +81 -0
  341. package/skills/nitro/docs/examples/custom-error-handler.md +98 -0
  342. package/skills/nitro/docs/examples/database.md +157 -0
  343. package/skills/nitro/docs/examples/elysia.md +70 -0
  344. package/skills/nitro/docs/examples/express.md +78 -0
  345. package/skills/nitro/docs/examples/fastify.md +79 -0
  346. package/skills/nitro/docs/examples/hello-world.md +68 -0
  347. package/skills/nitro/docs/examples/hono.md +74 -0
  348. package/skills/nitro/docs/examples/import-alias.md +100 -0
  349. package/skills/nitro/docs/examples/index.md +3 -0
  350. package/skills/nitro/docs/examples/middleware.md +91 -0
  351. package/skills/nitro/docs/examples/mono-jsx.md +68 -0
  352. package/skills/nitro/docs/examples/nano-jsx.md +70 -0
  353. package/skills/nitro/docs/examples/plugins.md +91 -0
  354. package/skills/nitro/docs/examples/renderer.md +113 -0
  355. package/skills/nitro/docs/examples/runtime-config.md +97 -0
  356. package/skills/nitro/docs/examples/server-fetch.md +87 -0
  357. package/skills/nitro/docs/examples/shiki.md +198 -0
  358. package/skills/nitro/docs/examples/virtual-routes.md +74 -0
  359. package/skills/nitro/docs/examples/vite-nitro-plugin.md +79 -0
  360. package/skills/nitro/docs/examples/vite-rsc.md +1041 -0
  361. package/skills/nitro/docs/examples/vite-ssr-html.md +217 -0
  362. package/skills/nitro/docs/examples/vite-ssr-preact.md +247 -0
  363. package/skills/nitro/docs/examples/vite-ssr-react.md +226 -0
  364. package/skills/nitro/docs/examples/vite-ssr-solid.md +256 -0
  365. package/skills/nitro/docs/examples/vite-ssr-tsr-react.md +442 -0
  366. package/skills/nitro/docs/examples/vite-ssr-tss-react.md +444 -0
  367. package/skills/nitro/docs/examples/vite-ssr-vue-router.md +616 -0
  368. package/skills/nitro/docs/examples/vite-trpc.md +335 -0
  369. package/skills/nitro/docs/examples/websocket.md +282 -0
  370. package/skills/nitro/docs/index.md +121 -0
@@ -0,0 +1,711 @@
1
+ # Routing
2
+
3
+ > Nitro supports filesystem routing to automatically map files to routes. By combining code-splitting with compiled routes, it removes the need for a runtime router, leaving only minimal compiled logic.
4
+
5
+ ## Request handler
6
+
7
+ Nitro request handler is a function accepting an `event` object, which is a [H3Event](https://h3.dev/guide/api/h3event#h3event-properties) object.
8
+
9
+ <code-group>
10
+
11
+ ```ts [Single function]
12
+ import type { H3Event } from "nitro";
13
+
14
+ export default (event: H3Event) => {
15
+ return "world";
16
+ }
17
+ ```
18
+
19
+ ```ts [defineHandler]
20
+ import { defineHandler } from "nitro";
21
+
22
+ // For better type inference
23
+ export default defineHandler((event) => {
24
+ return "world";
25
+ });
26
+ ```
27
+ </code-group>
28
+
29
+ ## Filesystem routing
30
+
31
+ Nitro supports file-based routing for your API routes (files are automatically mapped to [h3 routes](https://h3.dev/guide/basics/routing)). Defining a route is as simple as creating a file inside the `api/` or `routes/` directory.
32
+
33
+ You can only define one handler per files and you can [append the HTTP method](#specific-request-method) to the filename to define a specific request method.
34
+
35
+ ```
36
+ routes/
37
+ api/
38
+ test.ts <-- /api/test
39
+ hello.get.ts <-- /hello (GET only)
40
+ hello.post.ts <-- /hello (POST only)
41
+ vite.config.ts
42
+ ```
43
+
44
+ You can nest routes by creating subdirectories.
45
+
46
+ ```txt
47
+ routes/
48
+ api/
49
+ [org]/
50
+ [repo]/
51
+ index.ts <-- /api/:org/:repo
52
+ issues.ts <-- /api/:org/:repo/issues
53
+ index.ts <-- /api/:org
54
+ package.json
55
+ ```
56
+
57
+ #### Route Groups
58
+
59
+ In some cases, you may want to group a set of routes together in a way which doesn't affect file-based routing. For this purpose, you can put files in a folder which is wrapped in parentheses `(` and `)`.
60
+
61
+ For example:
62
+
63
+ ```txt
64
+ routes/
65
+ api/
66
+ (admin)/
67
+ users.ts <-- /api/users
68
+ reports.ts <-- /api/reports
69
+ (public)/
70
+ index.ts <-- /api
71
+ package.json
72
+ ```
73
+
74
+ > [!NOTE] The route groups are not part of the route definition and are only used for organization purposes.
75
+
76
+ ### Static routes
77
+
78
+ First, create a file in `routes/` or `routes/api/` directory. The filename will be the route path.
79
+
80
+ Then, export a fetch-compatible function:
81
+
82
+ ```ts [routes/api/test.ts]
83
+ import { defineHandler } from "nitro";
84
+
85
+ export default defineHandler(() => {
86
+ return { hello: "API" };
87
+ });
88
+ ```
89
+
90
+ ### Dynamic routes
91
+
92
+ #### Single param
93
+
94
+ To define a route with params, use the `[<param>]` syntax where `<param>` is the name of the param. The param will be available in the `event.context.params` object or using the [`getRouterParam`](https://h3.dev/utils/request#getrouterparamevent-name-opts-decode) utility.
95
+
96
+ ```ts [routes/hello/[name\].ts]
97
+ import { defineHandler } from "nitro";
98
+
99
+ export default defineHandler((event) => {
100
+ const { name } = event.context.params;
101
+
102
+ return `Hello ${name}!`;
103
+ });
104
+ ```
105
+
106
+ Call the route with the param `/hello/nitro`, you will get:
107
+
108
+ ```txt [Response]
109
+ Hello nitro!
110
+ ```
111
+
112
+ #### Multiple params
113
+
114
+ You can define multiple params in a route using `[<param1>]/[<param2>]` syntax where each param is a folder. You **cannot** define multiple params in a single filename of folder.
115
+
116
+ ```ts [routes/hello/[name\]/[age\].ts]
117
+ import { defineHandler } from "nitro";
118
+
119
+ export default defineHandler((event) => {
120
+ const { name, age } = event.context.params;
121
+
122
+ return `Hello ${name}! You are ${age} years old.`;
123
+ });
124
+ ```
125
+
126
+ #### Catch-all params
127
+
128
+ You can capture all the remaining parts of a URL using `[...<param>]` syntax. This will include the `/` in the param.
129
+
130
+ ```ts [routes/hello/[...name\].ts]
131
+ import { defineHandler } from "nitro";
132
+
133
+ export default defineHandler((event) => {
134
+ const { name } = event.context.params;
135
+
136
+ return `Hello ${name}!`;
137
+ });
138
+ ```
139
+
140
+ Call the route with the param `/hello/nitro/is/hot`, you will get:
141
+
142
+ ```txt [Response]
143
+ Hello nitro/is/hot!
144
+ ```
145
+
146
+ ### Specific request method
147
+
148
+ You can append the HTTP method to the filename to force the route to be matched only for a specific HTTP request method, for example `hello.get.ts` will only match for `GET` requests. You can use any HTTP method you want.
149
+
150
+ Supported methods: `get`, `post`, `put`, `delete`, `patch`, `head`, `options`, `connect`, `trace`.
151
+
152
+ <code-group>
153
+
154
+ ```js [GET]
155
+ // routes/users/[id].get.ts
156
+ import { defineHandler } from "nitro";
157
+
158
+ export default defineHandler(async (event) => {
159
+ const { id } = event.context.params;
160
+
161
+ // Do something with id
162
+
163
+ return `User profile!`;
164
+ });
165
+ ```
166
+
167
+ ```js [POST]
168
+ // routes/users.post.ts
169
+ import { defineHandler } from "nitro";
170
+
171
+ export default defineHandler(async (event) => {
172
+ const body = await event.req.json();
173
+
174
+ // Do something with body like saving it to a database
175
+
176
+ return { updated: true };
177
+ });
178
+ ```
179
+ </code-group>
180
+
181
+ ### Catch-all route
182
+
183
+ You can create a special route that will match all routes that are not matched by any other route. This is useful for creating a default route.
184
+
185
+ To create a catch-all route, create a file named `[...].ts`.
186
+
187
+ ```ts [routes/[...\].ts]
188
+ import { defineHandler } from "nitro";
189
+
190
+ export default defineHandler((event) => {
191
+ return `Hello ${event.url}!`;
192
+ });
193
+ ```
194
+
195
+ ### Environment specific handlers
196
+
197
+ You can specify for a route that will only be included in specific builds by adding a `.dev`, `.prod` or `.prerender` suffix to the file name, for example: `routes/test.get.dev.ts` or `routes/test.get.prod.ts`.
198
+
199
+ The suffix is placed after the method suffix (if any):
200
+
201
+ ```txt
202
+ routes/
203
+ env/
204
+ index.dev.ts <-- /env (dev only)
205
+ index.get.prod.ts <-- /env (GET, prod only)
206
+ ```
207
+
208
+ > [!TIP]
209
+ > You can specify multiple environments or specify a preset name as environment using programmatic registration of routes via [`routes`](#routes-config) config.
210
+
211
+ ### Ignoring files
212
+
213
+ You can use the `ignore` config option to exclude files from route scanning. It accepts an array of glob patterns relative to the server directory.
214
+
215
+ ```ts [nitro.config.ts]
216
+ import { defineNitroConfig } from "nitro/config";
217
+
218
+ export default defineNitroConfig({
219
+ ignore: [
220
+ "routes/api/**/_*", // Ignore files starting with _ in api/
221
+ "middleware/_*.ts", // Ignore middleware starting with _
222
+ "routes/_*.ts", // Ignore root routes starting with _
223
+ ],
224
+ });
225
+ ```
226
+
227
+ ## Programmatic route handlers
228
+
229
+ In addition to filesystem routing, you can register route handlers programmatically using the `routes` config option.
230
+
231
+ ### `routes` config
232
+
233
+ The `routes` option allows you to map route patterns to handlers:
234
+
235
+ ```ts [nitro.config.ts]
236
+ import { defineNitroConfig } from "nitro/config";
237
+
238
+ export default defineNitroConfig({
239
+ routes: {
240
+ "/api/hello": "./server/routes/api/hello.ts",
241
+ "/api/custom": {
242
+ handler: "./server/routes/api/hello.ts",
243
+ method: "POST",
244
+ lazy: true,
245
+ },
246
+ "/virtual": {
247
+ handler: "#virtual-route",
248
+ },
249
+ },
250
+ });
251
+ ```
252
+
253
+ Each route entry can be a simple string (handler path) or an object with the following options:
254
+
255
+ | Option | Type | Description |
256
+ | --- | --- | --- |
257
+ | `handler` | `string` | Path to event handler file or virtual module ID |
258
+ | `method` | `string` | HTTP method to match (`get`, `post`, etc.) |
259
+ | `lazy` | `boolean` | Use lazy loading to import handler |
260
+ | `format` | `"web" \| "node"` | Handler type. `"node"` handlers are converted to web-compatible |
261
+ | `env` | `string \| string[]` | Environments to include this handler (`"dev"`, `"prod"`, `"prerender"`, or a preset name) |
262
+
263
+ ### `handlers` config
264
+
265
+ The `handlers` array is useful for registering middleware with control over route matching:
266
+
267
+ ```ts [nitro.config.ts]
268
+ import { defineNitroConfig } from "nitro/config";
269
+
270
+ export default defineNitroConfig({
271
+ handlers: [
272
+ {
273
+ route: "/api/**",
274
+ handler: "./server/middleware/api-auth.ts",
275
+ middleware: true,
276
+ },
277
+ ],
278
+ });
279
+ ```
280
+
281
+ Each handler entry supports the following options:
282
+
283
+ | Option | Type | Description |
284
+ | --- | --- | --- |
285
+ | `route` | `string` | HTTP pathname pattern (e.g., `/test`, `/api/:id`, `/blog/**`) |
286
+ | `handler` | `string` | Path to event handler file or virtual module ID |
287
+ | `method` | `string` | HTTP method to match (`get`, `post`, etc.) |
288
+ | `middleware` | `boolean` | Run handler as middleware before route handlers |
289
+ | `lazy` | `boolean` | Use lazy loading to import handler |
290
+ | `format` | `"web" \| "node"` | Handler type. `"node"` handlers are converted to web-compatible |
291
+ | `env` | `string \| string[]` | Environments to include this handler (`"dev"`, `"prod"`, `"prerender"`, or a preset name) |
292
+
293
+ ## Middleware
294
+
295
+ Nitro route middleware can hook into the request lifecycle.
296
+
297
+ <tip>
298
+
299
+ A middleware can modify the request before it is processed, not after.
300
+ </tip>
301
+
302
+ Middleware are auto-registered within the `middleware/` directory.
303
+
304
+ ```md
305
+ middleware/
306
+ auth.ts
307
+ logger.ts
308
+ ...
309
+ routes/
310
+ hello.ts
311
+ ```
312
+
313
+ ### Simple middleware
314
+
315
+ Middleware are defined exactly like route handlers with the only exception that they should not return anything.
316
+ Returning from middleware behaves like returning from a request - the value will be returned as a response and further code will not be ran.
317
+
318
+ ```ts [middleware/auth.ts]
319
+ import { defineHandler } from "nitro";
320
+
321
+ export default defineHandler((event) => {
322
+ // Extends or modify the event
323
+ event.context.user = { name: "Nitro" };
324
+ });
325
+ ```
326
+
327
+ Middleware in `middleware/` directory are automatically registered for all routes. If you want to register a middleware for a specific route, see [Object Syntax Event Handler](https://h3.dev/guide/basics/handler#object-syntax).
328
+
329
+ <note>
330
+
331
+ Returning anything from a middleware will close the request and should be avoided! Any returned value from middleware will be the response and further code will not be executed however **this is not recommended to do!**
332
+ </note>
333
+
334
+ ### Route Meta
335
+
336
+ You can define route handler meta at build-time using `defineRouteMeta` macro in the event handler files.
337
+
338
+ > [!IMPORTANT]
339
+ > This feature is currently experimental.
340
+
341
+ ```ts [routes/api/test.ts]
342
+ import { defineRouteMeta } from "nitro";
343
+ import { defineHandler } from "nitro";
344
+
345
+ defineRouteMeta({
346
+ openAPI: {
347
+ tags: ["test"],
348
+ description: "Test route description",
349
+ parameters: [{ in: "query", name: "test", required: true }],
350
+ },
351
+ });
352
+
353
+ export default defineHandler(() => "OK");
354
+ ```
355
+
356
+ <read-more>
357
+
358
+ This feature is currently usable to specify OpenAPI meta. See swagger specification for available OpenAPI options.
359
+ </read-more>
360
+
361
+ ### Execution order
362
+
363
+ Middleware are executed in directory listing order.
364
+
365
+ ```md
366
+ middleware/
367
+ auth.ts <-- First
368
+ logger.ts <-- Second
369
+ ... <-- Third
370
+ ```
371
+
372
+ Prefix middleware with a number to control their execution order.
373
+
374
+ ```md
375
+ middleware/
376
+ 1.logger.ts <-- First
377
+ 2.auth.ts <-- Second
378
+ 3.... <-- Third
379
+ ```
380
+
381
+ <note>
382
+
383
+ Remember that file names are sorted as strings, thus for example if you have 3 files `1.filename.ts`, `2.filename.ts` and `10.filename.ts`, the `10.filename.ts` will come after the `1.filename.ts`. To avoid this, prefix `1-9` with a `0` like `01`, if you have more than 10 middleware in the same directory.
384
+ </note>
385
+
386
+ ### Request filtering
387
+
388
+ Middleware are executed on every request.
389
+
390
+ Apply custom logic to scope them to specific conditions.
391
+
392
+ For example, you can use the URL to apply a middleware to a specific route:
393
+
394
+ ```ts [middleware/auth.ts]
395
+ import { defineHandler } from "nitro";
396
+
397
+ export default defineHandler((event) => {
398
+ // Will only execute for /auth route
399
+ if (event.url.pathname.startsWith('/auth')) {
400
+ event.context.user = { name: "Nitro" };
401
+ }
402
+ });
403
+ ```
404
+
405
+ ### Route-scoped middleware
406
+
407
+ You can register middleware for specific route patterns using the [`handlers`](#handlers-config) config with the `middleware` option and a specific `route`:
408
+
409
+ ```ts [nitro.config.ts]
410
+ import { defineNitroConfig } from "nitro/config";
411
+
412
+ export default defineNitroConfig({
413
+ handlers: [
414
+ {
415
+ route: "/api/**",
416
+ handler: "./server/middleware/api-auth.ts",
417
+ middleware: true,
418
+ },
419
+ ],
420
+ });
421
+ ```
422
+
423
+ Unlike global middleware (registered in the `middleware/` directory which match `/**`), route-scoped middleware only run for requests matching the specified pattern.
424
+
425
+ ## Error handling
426
+
427
+ You can use the [utilities available in H3](https://h3.dev/guide/basics/error) to handle errors in both routes and middlewares.
428
+
429
+ The way errors are sent back to the client depends on the environment. In development, requests with an `Accept` header of `text/html` (such as browsers) will receive a HTML error page. In production, errors are always sent in JSON.
430
+
431
+ This behaviour can be overridden by some request properties (e.g.: `Accept` or `User-Agent` headers).
432
+
433
+ ## Code splitting
434
+
435
+ Nitro creates a separate chunk for each route handler. Chunks load on-demand when first requested, so `/api/users` doesn't load code for `/api/posts`.
436
+
437
+ See [`inlineDynamicImports`](/config#inlinedynamicimports) to bundle everything into a single file.
438
+
439
+ ## Route rules
440
+
441
+ Nitro allows you to add logic at the top-level for each route of your configuration. It can be used for redirecting, proxying, caching, authentication, and adding headers to routes.
442
+
443
+ It is a map from route pattern (following [rou3](https://github.com/h3js/rou3)) to route options.
444
+
445
+ When `cache` option is set, handlers matching pattern will be automatically wrapped with `defineCachedEventHandler`. See the [cache guide](/docs/cache) to learn more about this function.
446
+
447
+ <note>
448
+
449
+ `swr: true|number` is shortcut for `cache: { swr: true, maxAge: number }`
450
+ </note>
451
+
452
+ You can set route rules in the `nitro.routeRules` options.
453
+
454
+ ```ts [nitro.config.ts]
455
+ import { defineNitroConfig } from "nitro/config";
456
+
457
+ export default defineNitroConfig({
458
+ routeRules: {
459
+ '/blog/**': { swr: true },
460
+ '/blog/**': { swr: 600 },
461
+ '/blog/**': { static: true },
462
+ '/blog/**': { cache: { /* cache options*/ } },
463
+ '/assets/**': { headers: { 'cache-control': 's-maxage=0' } },
464
+ '/api/v1/**': { cors: true, headers: { 'access-control-allow-methods': 'GET' } },
465
+ '/old-page': { redirect: '/new-page' },
466
+ '/old-page/**': { redirect: '/new-page/**' },
467
+ '/proxy/example': { proxy: 'https://example.com' },
468
+ '/proxy/**': { proxy: '/api/**' },
469
+ '/admin/**': { basicAuth: { username: 'admin', password: 'supersecret' } },
470
+ }
471
+ });
472
+ ```
473
+
474
+ ### Rule merging and overrides
475
+
476
+ Route rules are matched from least specific to most specific. When multiple rules match a request, their options are merged, with more specific rules taking precedence.
477
+
478
+ You can use `false` to disable a rule that was set by a more general pattern:
479
+
480
+ ```ts [nitro.config.ts]
481
+ import { defineNitroConfig } from "nitro/config";
482
+
483
+ export default defineNitroConfig({
484
+ routeRules: {
485
+ '/api/cached/**': { swr: true },
486
+ '/api/cached/no-cache': { cache: false, swr: false },
487
+ '/admin/**': { basicAuth: { username: 'admin', password: 'secret' } },
488
+ '/admin/public/**': { basicAuth: false },
489
+ }
490
+ });
491
+ ```
492
+
493
+ ### Headers
494
+
495
+ Set custom response headers for matching routes:
496
+
497
+ ```ts [nitro.config.ts]
498
+ import { defineNitroConfig } from "nitro/config";
499
+
500
+ export default defineNitroConfig({
501
+ routeRules: {
502
+ '/api/**': { headers: { 'cache-control': 's-maxage=60' } },
503
+ '**': { headers: { 'x-powered-by': 'Nitro' } },
504
+ }
505
+ });
506
+ ```
507
+
508
+ ### CORS
509
+
510
+ Enable CORS headers with the `cors: true` shortcut. This sets `access-control-allow-origin: *`, `access-control-allow-methods: *`, `access-control-allow-headers: *`, and `access-control-max-age: 0`.
511
+
512
+ You can override individual CORS headers using `headers`:
513
+
514
+ ```ts [nitro.config.ts]
515
+ import { defineNitroConfig } from "nitro/config";
516
+
517
+ export default defineNitroConfig({
518
+ routeRules: {
519
+ '/api/v1/**': {
520
+ cors: true,
521
+ headers: { 'access-control-allow-methods': 'GET' },
522
+ },
523
+ }
524
+ });
525
+ ```
526
+
527
+ ### Redirect
528
+
529
+ Redirect matching routes to another URL. Use a string for a simple redirect (defaults to `307` status), or an object for more control:
530
+
531
+ ```ts [nitro.config.ts]
532
+ import { defineNitroConfig } from "nitro/config";
533
+
534
+ export default defineNitroConfig({
535
+ routeRules: {
536
+ // Simple redirect (307 status)
537
+ '/old-page': { redirect: '/new-page' },
538
+ // Redirect with custom status
539
+ '/legacy': { redirect: { to: 'https://example.com/', status: 308 } },
540
+ // Wildcard redirect — preserves the path after the pattern
541
+ '/old-blog/**': { redirect: 'https://blog.example.com/**' },
542
+ }
543
+ });
544
+ ```
545
+
546
+ ### Proxy
547
+
548
+ Proxy requests to another URL. Supports both internal and external targets:
549
+
550
+ ```ts [nitro.config.ts]
551
+ import { defineNitroConfig } from "nitro/config";
552
+
553
+ export default defineNitroConfig({
554
+ routeRules: {
555
+ // Proxy to exact URL
556
+ '/api/proxy/example': { proxy: 'https://example.com' },
557
+ // Proxy to internal route
558
+ '/api/proxy/**': { proxy: '/api/echo' },
559
+ // Wildcard proxy — preserves the path after the pattern
560
+ '/cdn/**': { proxy: 'https://cdn.jsdelivr.net/**' },
561
+ // Proxy with options
562
+ '/external/**': {
563
+ proxy: {
564
+ to: 'https://api.example.com/**',
565
+ // Additional H3 proxy options...
566
+ },
567
+ },
568
+ }
569
+ });
570
+ ```
571
+
572
+ ### Basic auth
573
+
574
+ Protect routes with HTTP Basic Authentication:
575
+
576
+ ```ts [nitro.config.ts]
577
+ import { defineNitroConfig } from "nitro/config";
578
+
579
+ export default defineNitroConfig({
580
+ routeRules: {
581
+ '/admin/**': {
582
+ basicAuth: {
583
+ username: 'admin',
584
+ password: 'supersecret',
585
+ realm: 'Admin Area', // Optional, shown in the browser prompt
586
+ },
587
+ },
588
+ // Disable basic auth for a sub-path
589
+ '/admin/public/**': { basicAuth: false },
590
+ }
591
+ });
592
+ ```
593
+
594
+ ### Caching (SWR / Static)
595
+
596
+ Control caching behavior with `cache`, `swr`, or `static` options:
597
+
598
+ ```ts [nitro.config.ts]
599
+ import { defineNitroConfig } from "nitro/config";
600
+
601
+ export default defineNitroConfig({
602
+ routeRules: {
603
+ // Enable stale-while-revalidate caching
604
+ '/blog/**': { swr: true },
605
+ // SWR with maxAge in seconds
606
+ '/blog/posts/**': { swr: 600 },
607
+ // Full cache options
608
+ '/api/data/**': {
609
+ cache: {
610
+ maxAge: 60,
611
+ swr: true,
612
+ // ...other cache options
613
+ },
614
+ },
615
+ // Disable caching
616
+ '/api/realtime/**': { cache: false },
617
+ }
618
+ });
619
+ ```
620
+
621
+ <tip>
622
+
623
+ `swr: true` is a shortcut for `cache: { swr: true }` and `swr: <number>` is a shortcut for `cache: { swr: true, maxAge: <number> }`.
624
+ </tip>
625
+
626
+ ### Prerender
627
+
628
+ Mark routes for prerendering at build time:
629
+
630
+ ```ts [nitro.config.ts]
631
+ import { defineNitroConfig } from "nitro/config";
632
+
633
+ export default defineNitroConfig({
634
+ routeRules: {
635
+ '/about': { prerender: true },
636
+ '/dynamic/**': { prerender: false },
637
+ }
638
+ });
639
+ ```
640
+
641
+ ### ISR (Vercel)
642
+
643
+ Configure Incremental Static Regeneration for Vercel deployments:
644
+
645
+ ```ts [nitro.config.ts]
646
+ import { defineNitroConfig } from "nitro/config";
647
+
648
+ export default defineNitroConfig({
649
+ routeRules: {
650
+ '/isr/**': { isr: true },
651
+ '/isr-ttl/**': { isr: 60 },
652
+ '/isr-custom/**': {
653
+ isr: {
654
+ expiration: 60,
655
+ allowQuery: ['q'],
656
+ group: 1,
657
+ },
658
+ },
659
+ }
660
+ });
661
+ ```
662
+
663
+ ### Route rules reference
664
+
665
+ | Option | Type | Description |
666
+ | --- | --- | --- |
667
+ | `headers` | `Record<string, string>` | Custom response headers |
668
+ | `redirect` | `string \| { to: string, status?: number }` | Redirect to another URL (default status: `307`) |
669
+ | `proxy` | `string \| { to: string, ...proxyOptions }` | Proxy requests to another URL |
670
+ | `cors` | `boolean` | Enable permissive CORS headers |
671
+ | `cache` | `object \| false` | Cache options (see [cache guide](/docs/cache)) |
672
+ | `swr` | `boolean \| number` | Shortcut for `cache: { swr: true, maxAge: number }` |
673
+ | `static` | `boolean \| number` | Shortcut for static caching |
674
+ | `basicAuth` | `{ username, password, realm? } \| false` | HTTP Basic Authentication |
675
+ | `prerender` | `boolean` | Enable/disable prerendering |
676
+ | `isr` | `boolean \| number \| object` | Incremental Static Regeneration (Vercel) |
677
+
678
+ ### Runtime route rules
679
+
680
+ Route rules can be provided through `runtimeConfig`, allowing overrides via environment variables without rebuilding:
681
+
682
+ ```ts [nitro.config.ts]
683
+ import { defineNitroConfig } from "nitro/config";
684
+
685
+ export default defineNitroConfig({
686
+ runtimeConfig: {
687
+ nitro: {
688
+ routeRules: {
689
+ '/api/**': { headers: { 'x-env': 'production' } },
690
+ },
691
+ },
692
+ },
693
+ });
694
+ ```
695
+
696
+ ## Config reference
697
+
698
+ These config options control routing behavior:
699
+
700
+ | Option | Type | Default | Description |
701
+ | --- | --- | --- | --- |
702
+ | `baseURL` | `string` | `"/"` | Base URL for all routes |
703
+ | `apiBaseURL` | `string` | `"/api"` | Base URL for routes in the `api/` directory |
704
+ | `apiDir` | `string` | `"api"` | Directory name for API routes |
705
+ | `routesDir` | `string` | `"routes"` | Directory name for file-based routes |
706
+ | `serverDir` | `string \| false` | `false` | Server directory for scanning routes, middleware, plugins, etc. |
707
+ | `scanDirs` | `string[]` | `[]` | Additional directories to scan for routes |
708
+ | `routes` | `Record<string, string \| handler>` | `{}` | Route-to-handler mapping |
709
+ | `handlers` | `NitroEventHandler[]` | `[]` | Programmatic handler registration (mainly for middleware) |
710
+ | `routeRules` | `Record<string, NitroRouteConfig>` | `{}` | Route rules for matching patterns |
711
+ | `ignore` | `string[]` | `[]` | Glob patterns to ignore during file scanning |