@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.
- package/LICENSE +27 -0
- package/README.md +32 -0
- package/changes.json +14 -0
- package/dist/THIRD-PARTY-LICENSES.md +1646 -0
- package/dist/_build/common.mjs +29361 -0
- package/dist/_build/rolldown.mjs +173 -0
- package/dist/_build/rollup.mjs +194 -0
- package/dist/_build/vite.build.mjs +18 -0
- package/dist/_chunks/nitro.mjs +1159 -0
- package/dist/_chunks/nitro2.mjs +102 -0
- package/dist/_chunks/nitro3.mjs +129 -0
- package/dist/_chunks/utils.mjs +272 -0
- package/dist/_common.mjs +35 -0
- package/dist/_dev.d.mts +12 -0
- package/dist/_dev.mjs +519 -0
- package/dist/_libs/_.mjs +3 -0
- package/dist/_libs/_2.mjs +2 -0
- package/dist/_libs/_3.mjs +3 -0
- package/dist/_libs/_4.mjs +2 -0
- package/dist/_libs/_5.mjs +3 -0
- package/dist/_libs/_6.mjs +4 -0
- package/dist/_libs/_7.mjs +5 -0
- package/dist/_libs/c12+rc9.mjs +812 -0
- package/dist/_libs/c12+readdirp+chokidar.d.mts +230 -0
- package/dist/_libs/citty.mjs +361 -0
- package/dist/_libs/commondir+is-reference.mjs +1311 -0
- package/dist/_libs/compatx.d.mts +47 -0
- package/dist/_libs/compatx.mjs +45 -0
- package/dist/_libs/esbuild.d.mts +20 -0
- package/dist/_libs/escape-string-regexp.mjs +7 -0
- package/dist/_libs/estree+pluginutils.d.mts +241 -0
- package/dist/_libs/estree-walker.mjs +184 -0
- package/dist/_libs/exsolve.d.mts +1 -0
- package/dist/_libs/hasown+resolve+deepmerge.mjs +1949 -0
- package/dist/_libs/httpxy.d.mts +82 -0
- package/dist/_libs/httpxy.mjs +671 -0
- package/dist/_libs/js-tokens.d.mts +1 -0
- package/dist/_libs/klona.mjs +37 -0
- package/dist/_libs/magic-string.d.mts +220 -0
- package/dist/_libs/mlly.d.mts +57 -0
- package/dist/_libs/nypm+tinyexec.mjs +845 -0
- package/dist/_libs/perfect-debounce.mjs +88 -0
- package/dist/_libs/pkg-types.d.mts +23 -0
- package/dist/_libs/plugin-alias.mjs +64 -0
- package/dist/_libs/plugin-inject.mjs +131 -0
- package/dist/_libs/plugin-json.mjs +34 -0
- package/dist/_libs/pluginutils.mjs +646 -0
- package/dist/_libs/readdirp+chokidar.mjs +1606 -0
- package/dist/_libs/remapping.mjs +115 -0
- package/dist/_libs/resolve-uri+gen-mapping.mjs +442 -0
- package/dist/_libs/rou3.d.mts +44 -0
- package/dist/_libs/rou3.mjs +496 -0
- package/dist/_libs/std-env.d.mts +12 -0
- package/dist/_libs/strip-literal.d.mts +1 -0
- package/dist/_libs/tsconfck.mjs +813 -0
- package/dist/_libs/ultrahtml.mjs +127 -0
- package/dist/_libs/unimport+unplugin.mjs +1684 -0
- package/dist/_libs/unplugin+unimport.d.mts +423 -0
- package/dist/_libs/unwasm.d.mts +29 -0
- package/dist/_presets.mjs +1759 -0
- package/dist/builder.d.mts +64 -0
- package/dist/builder.mjs +15 -0
- package/dist/cli/_chunks/build.mjs +47 -0
- package/dist/cli/_chunks/common.mjs +14 -0
- package/dist/cli/_chunks/deploy.mjs +40 -0
- package/dist/cli/_chunks/dev.mjs +62 -0
- package/dist/cli/_chunks/docs.mjs +30 -0
- package/dist/cli/_chunks/list.mjs +25 -0
- package/dist/cli/_chunks/prepare.mjs +17 -0
- package/dist/cli/_chunks/preview.mjs +51 -0
- package/dist/cli/_chunks/run.mjs +53 -0
- package/dist/cli/_chunks/task.mjs +14 -0
- package/dist/cli/index.d.mts +1 -0
- package/dist/cli/index.mjs +22 -0
- package/dist/node_modules/@poppinss/colors/build/index.js +139 -0
- package/dist/node_modules/@poppinss/colors/package.json +118 -0
- package/dist/node_modules/@poppinss/dumper/build/chunk-26HALFTP.js +602 -0
- package/dist/node_modules/@poppinss/dumper/build/formatters/console/main.js +441 -0
- package/dist/node_modules/@poppinss/dumper/build/formatters/html/main.js +725 -0
- package/dist/node_modules/@poppinss/dumper/package.json +122 -0
- package/dist/node_modules/@poppinss/exception/build/index.js +44 -0
- package/dist/node_modules/@poppinss/exception/package.json +109 -0
- package/dist/node_modules/@sindresorhus/is/distribution/index.js +1354 -0
- package/dist/node_modules/@sindresorhus/is/distribution/utilities.js +3 -0
- package/dist/node_modules/@sindresorhus/is/package.json +81 -0
- package/dist/node_modules/@speed-highlight/core/dist/index.js +4 -0
- package/dist/node_modules/@speed-highlight/core/dist/terminal.js +2 -0
- package/dist/node_modules/@speed-highlight/core/package.json +94 -0
- package/dist/node_modules/cookie-es/dist/index.mjs +262 -0
- package/dist/node_modules/cookie-es/package.json +37 -0
- package/dist/node_modules/croner/dist/croner.js +1 -0
- package/dist/node_modules/croner/package.json +73 -0
- package/dist/node_modules/defu/dist/defu.mjs +69 -0
- package/dist/node_modules/defu/package.json +43 -0
- package/dist/node_modules/destr/dist/index.mjs +72 -0
- package/dist/node_modules/destr/package.json +47 -0
- package/dist/node_modules/error-stack-parser-es/dist/index.mjs +38 -0
- package/dist/node_modules/error-stack-parser-es/dist/lite.mjs +167 -0
- package/dist/node_modules/error-stack-parser-es/package.json +83 -0
- package/dist/node_modules/get-port-please/dist/index.mjs +430 -0
- package/dist/node_modules/get-port-please/package.json +39 -0
- package/dist/node_modules/kleur/index.mjs +110 -0
- package/dist/node_modules/kleur/package.json +51 -0
- package/dist/node_modules/rendu/dist/index.mjs +380 -0
- package/dist/node_modules/rendu/package.json +47 -0
- package/dist/node_modules/scule/dist/index.mjs +80 -0
- package/dist/node_modules/scule/package.json +43 -0
- package/dist/node_modules/source-map/lib/array-set.js +100 -0
- package/dist/node_modules/source-map/lib/base64-vlq.js +94 -0
- package/dist/node_modules/source-map/lib/base64.js +19 -0
- package/dist/node_modules/source-map/lib/binary-search.js +113 -0
- package/dist/node_modules/source-map/lib/mapping-list.js +83 -0
- package/dist/node_modules/source-map/lib/mappings.wasm +0 -0
- package/dist/node_modules/source-map/lib/read-wasm.js +27 -0
- package/dist/node_modules/source-map/lib/source-map-consumer.js +1081 -0
- package/dist/node_modules/source-map/lib/source-map-generator.js +439 -0
- package/dist/node_modules/source-map/lib/source-node.js +430 -0
- package/dist/node_modules/source-map/lib/url.js +13 -0
- package/dist/node_modules/source-map/lib/util.js +444 -0
- package/dist/node_modules/source-map/lib/wasm.js +138 -0
- package/dist/node_modules/source-map/package.json +79 -0
- package/dist/node_modules/source-map/source-map.js +10 -0
- package/dist/node_modules/supports-color/index.js +202 -0
- package/dist/node_modules/supports-color/package.json +64 -0
- package/dist/node_modules/ufo/dist/index.mjs +645 -0
- package/dist/node_modules/ufo/package.json +48 -0
- package/dist/node_modules/unctx/dist/index.mjs +131 -0
- package/dist/node_modules/unctx/package.json +67 -0
- package/dist/node_modules/youch/build/helpers-B9BQYaS6.js +23 -0
- package/dist/node_modules/youch/build/index.js +212 -0
- package/dist/node_modules/youch/build/public/error_cause/style.css +5 -0
- package/dist/node_modules/youch/build/public/error_info/script.js +13 -0
- package/dist/node_modules/youch/build/public/error_info/style.css +145 -0
- package/dist/node_modules/youch/build/public/error_metadata/style.css +3 -0
- package/dist/node_modules/youch/build/public/error_stack/script.js +72 -0
- package/dist/node_modules/youch/build/public/error_stack/style.css +219 -0
- package/dist/node_modules/youch/build/public/error_stack_source/style.css +123 -0
- package/dist/node_modules/youch/build/public/header/script.js +14 -0
- package/dist/node_modules/youch/build/public/header/style.css +56 -0
- package/dist/node_modules/youch/build/public/layout/script.js +12 -0
- package/dist/node_modules/youch/build/public/layout/style.css +435 -0
- package/dist/node_modules/youch/build/public_dir-C5bujZKB.js +25 -0
- package/dist/node_modules/youch/build/src/templates/error_cause/main.js +44 -0
- package/dist/node_modules/youch/build/src/templates/error_info/main.js +72 -0
- package/dist/node_modules/youch/build/src/templates/error_metadata/main.js +65 -0
- package/dist/node_modules/youch/build/src/templates/error_stack/main.js +152 -0
- package/dist/node_modules/youch/build/src/templates/error_stack_source/main.js +46 -0
- package/dist/node_modules/youch/build/src/templates/header/main.js +24 -0
- package/dist/node_modules/youch/build/src/templates/layout/main.js +27 -0
- package/dist/node_modules/youch/package.json +135 -0
- package/dist/node_modules/youch-core/build/index.js +316 -0
- package/dist/node_modules/youch-core/package.json +124 -0
- package/dist/presets/_nitro/runtime/nitro-dev.mjs +20 -0
- package/dist/presets/_nitro/runtime/nitro-prerenderer.mjs +15 -0
- package/dist/presets/_nitro/runtime/service-worker.mjs +23 -0
- package/dist/presets/aws-amplify/runtime/aws-amplify.mjs +14 -0
- package/dist/presets/aws-lambda/runtime/_utils.mjs +116 -0
- package/dist/presets/aws-lambda/runtime/aws-lambda-streaming.mjs +31 -0
- package/dist/presets/aws-lambda/runtime/aws-lambda.mjs +13 -0
- package/dist/presets/azure/runtime/_utils.mjs +50 -0
- package/dist/presets/azure/runtime/azure-swa.mjs +30 -0
- package/dist/presets/bun/runtime/bun.mjs +40 -0
- package/dist/presets/cloudflare/runtime/_module-handler.mjs +87 -0
- package/dist/presets/cloudflare/runtime/cloudflare-durable.mjs +72 -0
- package/dist/presets/cloudflare/runtime/cloudflare-module.mjs +17 -0
- package/dist/presets/cloudflare/runtime/cloudflare-pages.mjs +39 -0
- package/dist/presets/cloudflare/runtime/plugin.dev.mjs +96 -0
- package/dist/presets/cloudflare/runtime/shims/workers.dev.mjs +27 -0
- package/dist/presets/deno/runtime/deno-deploy.mjs +19 -0
- package/dist/presets/deno/runtime/deno-server.mjs +39 -0
- package/dist/presets/netlify/runtime/netlify-edge.mjs +20 -0
- package/dist/presets/netlify/runtime/netlify.mjs +20 -0
- package/dist/presets/node/runtime/node-cluster.mjs +54 -0
- package/dist/presets/node/runtime/node-middleware.mjs +14 -0
- package/dist/presets/node/runtime/node-server.mjs +47 -0
- package/dist/presets/standard/runtime/server.mjs +4 -0
- package/dist/presets/stormkit/runtime/stormkit.mjs +27 -0
- package/dist/presets/vercel/runtime/cron-handler.mjs +25 -0
- package/dist/presets/vercel/runtime/isr.mjs +19 -0
- package/dist/presets/vercel/runtime/vercel.node.mjs +24 -0
- package/dist/presets/vercel/runtime/vercel.web.mjs +23 -0
- package/dist/presets/winterjs/runtime/winterjs.mjs +91 -0
- package/dist/presets/zeabur/runtime/zeabur.mjs +4 -0
- package/dist/presets/zephyr/runtime/server.mjs +3 -0
- package/dist/runtime/app.d.mts +1 -0
- package/dist/runtime/app.mjs +1 -0
- package/dist/runtime/cache.d.mts +1 -0
- package/dist/runtime/cache.mjs +1 -0
- package/dist/runtime/config.d.mts +3 -0
- package/dist/runtime/config.mjs +4 -0
- package/dist/runtime/context.d.mts +1 -0
- package/dist/runtime/context.mjs +1 -0
- package/dist/runtime/database.d.mts +1 -0
- package/dist/runtime/database.mjs +1 -0
- package/dist/runtime/internal/app.d.mts +16 -0
- package/dist/runtime/internal/app.mjs +208 -0
- package/dist/runtime/internal/cache.d.mts +7 -0
- package/dist/runtime/internal/cache.mjs +41 -0
- package/dist/runtime/internal/context.d.mts +14 -0
- package/dist/runtime/internal/context.mjs +24 -0
- package/dist/runtime/internal/database.d.mts +2 -0
- package/dist/runtime/internal/database.mjs +12 -0
- package/dist/runtime/internal/empty.mjs +0 -0
- package/dist/runtime/internal/error/dev.d.mts +10 -0
- package/dist/runtime/internal/error/dev.mjs +121 -0
- package/dist/runtime/internal/error/hooks.d.mts +1 -0
- package/dist/runtime/internal/error/hooks.mjs +9 -0
- package/dist/runtime/internal/error/prod.d.mts +6 -0
- package/dist/runtime/internal/error/prod.mjs +40 -0
- package/dist/runtime/internal/error/utils.d.mts +8 -0
- package/dist/runtime/internal/error/utils.mjs +3 -0
- package/dist/runtime/internal/meta.d.mts +2 -0
- package/dist/runtime/internal/meta.mjs +3 -0
- package/dist/runtime/internal/plugin.d.mts +3 -0
- package/dist/runtime/internal/plugin.mjs +4 -0
- package/dist/runtime/internal/route-rules.d.mts +9 -0
- package/dist/runtime/internal/route-rules.mjs +72 -0
- package/dist/runtime/internal/routes/dev-tasks.d.mts +3 -0
- package/dist/runtime/internal/routes/dev-tasks.mjs +25 -0
- package/dist/runtime/internal/routes/openapi.d.mts +3 -0
- package/dist/runtime/internal/routes/openapi.mjs +94 -0
- package/dist/runtime/internal/routes/renderer-template.d.mts +2 -0
- package/dist/runtime/internal/routes/renderer-template.dev.d.mts +3 -0
- package/dist/runtime/internal/routes/renderer-template.dev.mjs +19 -0
- package/dist/runtime/internal/routes/renderer-template.mjs +4 -0
- package/dist/runtime/internal/routes/scalar.d.mts +3 -0
- package/dist/runtime/internal/routes/scalar.mjs +193 -0
- package/dist/runtime/internal/routes/swagger.d.mts +3 -0
- package/dist/runtime/internal/routes/swagger.mjs +42 -0
- package/dist/runtime/internal/runtime-config.d.mts +9 -0
- package/dist/runtime/internal/runtime-config.mjs +54 -0
- package/dist/runtime/internal/static.d.mts +3 -0
- package/dist/runtime/internal/static.mjs +67 -0
- package/dist/runtime/internal/storage.d.mts +2 -0
- package/dist/runtime/internal/storage.mjs +6 -0
- package/dist/runtime/internal/task.d.mts +19 -0
- package/dist/runtime/internal/task.mjs +69 -0
- package/dist/runtime/internal/vite/dev-entry.mjs +18 -0
- package/dist/runtime/internal/vite/dev-worker.mjs +264 -0
- package/dist/runtime/internal/vite/ssr-renderer.mjs +6 -0
- package/dist/runtime/meta.d.mts +5 -0
- package/dist/runtime/meta.mjs +27 -0
- package/dist/runtime/nitro.d.mts +11 -0
- package/dist/runtime/nitro.mjs +34 -0
- package/dist/runtime/runtime-config.d.mts +1 -0
- package/dist/runtime/runtime-config.mjs +1 -0
- package/dist/runtime/storage.d.mts +1 -0
- package/dist/runtime/storage.mjs +1 -0
- package/dist/runtime/task.d.mts +1 -0
- package/dist/runtime/task.mjs +1 -0
- package/dist/runtime/virtual/_runtime_warn.d.mts +1 -0
- package/dist/runtime/virtual/_runtime_warn.mjs +5 -0
- package/dist/runtime/virtual/database.d.mts +8 -0
- package/dist/runtime/virtual/database.mjs +2 -0
- package/dist/runtime/virtual/error-handler.d.mts +6 -0
- package/dist/runtime/virtual/error-handler.mjs +9 -0
- package/dist/runtime/virtual/feature-flags.d.mts +7 -0
- package/dist/runtime/virtual/feature-flags.mjs +7 -0
- package/dist/runtime/virtual/plugins.d.mts +3 -0
- package/dist/runtime/virtual/plugins.mjs +2 -0
- package/dist/runtime/virtual/polyfills.d.mts +3 -0
- package/dist/runtime/virtual/polyfills.mjs +2 -0
- package/dist/runtime/virtual/public-assets.d.mts +9 -0
- package/dist/runtime/virtual/public-assets.mjs +8 -0
- package/dist/runtime/virtual/renderer-template.d.mts +4 -0
- package/dist/runtime/virtual/renderer-template.mjs +7 -0
- package/dist/runtime/virtual/routing-meta.d.mts +7 -0
- package/dist/runtime/virtual/routing-meta.mjs +2 -0
- package/dist/runtime/virtual/routing.d.mts +8 -0
- package/dist/runtime/virtual/routing.mjs +11 -0
- package/dist/runtime/virtual/runtime-config.d.mts +3 -0
- package/dist/runtime/virtual/runtime-config.mjs +5 -0
- package/dist/runtime/virtual/server-assets.d.mts +7 -0
- package/dist/runtime/virtual/server-assets.mjs +12 -0
- package/dist/runtime/virtual/storage.d.mts +3 -0
- package/dist/runtime/virtual/storage.mjs +5 -0
- package/dist/runtime/virtual/tasks.d.mts +10 -0
- package/dist/runtime/virtual/tasks.mjs +3 -0
- package/dist/runtime/vite.d.mts +8 -0
- package/dist/runtime/vite.mjs +9 -0
- package/dist/types/index.d.mts +3010 -0
- package/dist/types/index.mjs +1 -0
- package/dist/vite.d.mts +52 -0
- package/dist/vite.mjs +740 -0
- package/lib/h3.d.mts +1 -0
- package/lib/h3.mjs +1 -0
- package/lib/tsconfig.json +27 -0
- package/lib/vite.types.d.mts +26 -0
- package/lib/vite.types.mjs +2 -0
- package/package.json +256 -0
- package/skills/nitro/SKILL.md +10 -0
- package/skills/nitro/docs/TOC.md +83 -0
- package/skills/nitro/docs/_navigation.json +679 -0
- package/skills/nitro/docs/config/index.md +1147 -0
- package/skills/nitro/docs/deploy/index.md +64 -0
- package/skills/nitro/docs/deploy/providers/alwaysdata.md +50 -0
- package/skills/nitro/docs/deploy/providers/aws-amplify.md +81 -0
- package/skills/nitro/docs/deploy/providers/aws.md +47 -0
- package/skills/nitro/docs/deploy/providers/azure.md +72 -0
- package/skills/nitro/docs/deploy/providers/cleavr.md +33 -0
- package/skills/nitro/docs/deploy/providers/cloudflare.md +375 -0
- package/skills/nitro/docs/deploy/providers/deno-deploy.md +66 -0
- package/skills/nitro/docs/deploy/providers/digitalocean.md +46 -0
- package/skills/nitro/docs/deploy/providers/firebase.md +32 -0
- package/skills/nitro/docs/deploy/providers/flightcontrol.md +67 -0
- package/skills/nitro/docs/deploy/providers/genezio.md +67 -0
- package/skills/nitro/docs/deploy/providers/github-pages.md +68 -0
- package/skills/nitro/docs/deploy/providers/gitlab-pages.md +37 -0
- package/skills/nitro/docs/deploy/providers/heroku.md +84 -0
- package/skills/nitro/docs/deploy/providers/iis.md +38 -0
- package/skills/nitro/docs/deploy/providers/koyeb.md +109 -0
- package/skills/nitro/docs/deploy/providers/netlify.md +47 -0
- package/skills/nitro/docs/deploy/providers/platform-sh.md +37 -0
- package/skills/nitro/docs/deploy/providers/render.md +37 -0
- package/skills/nitro/docs/deploy/providers/stormkit.md +24 -0
- package/skills/nitro/docs/deploy/providers/vercel.md +179 -0
- package/skills/nitro/docs/deploy/providers/zeabur.md +19 -0
- package/skills/nitro/docs/deploy/providers/zephyr.md +99 -0
- package/skills/nitro/docs/deploy/providers/zerops.md +102 -0
- package/skills/nitro/docs/deploy/runtimes/bun.md +15 -0
- package/skills/nitro/docs/deploy/runtimes/deno.md +19 -0
- package/skills/nitro/docs/deploy/runtimes/node.md +63 -0
- package/skills/nitro/docs/docs/assets.md +166 -0
- package/skills/nitro/docs/docs/cache.md +408 -0
- package/skills/nitro/docs/docs/configuration.md +256 -0
- package/skills/nitro/docs/docs/database.md +185 -0
- package/skills/nitro/docs/docs/index.md +56 -0
- package/skills/nitro/docs/docs/lifecycle.md +204 -0
- package/skills/nitro/docs/docs/migration.md +215 -0
- package/skills/nitro/docs/docs/nightly.md +31 -0
- package/skills/nitro/docs/docs/plugins.md +164 -0
- package/skills/nitro/docs/docs/quick-start.md +110 -0
- package/skills/nitro/docs/docs/renderer.md +322 -0
- package/skills/nitro/docs/docs/routing.md +711 -0
- package/skills/nitro/docs/docs/server-entry.md +239 -0
- package/skills/nitro/docs/docs/storage.md +261 -0
- package/skills/nitro/docs/docs/tasks.md +277 -0
- package/skills/nitro/docs/examples/api-routes.md +145 -0
- package/skills/nitro/docs/examples/auto-imports.md +93 -0
- package/skills/nitro/docs/examples/cached-handler.md +81 -0
- package/skills/nitro/docs/examples/custom-error-handler.md +98 -0
- package/skills/nitro/docs/examples/database.md +157 -0
- package/skills/nitro/docs/examples/elysia.md +70 -0
- package/skills/nitro/docs/examples/express.md +78 -0
- package/skills/nitro/docs/examples/fastify.md +79 -0
- package/skills/nitro/docs/examples/hello-world.md +68 -0
- package/skills/nitro/docs/examples/hono.md +74 -0
- package/skills/nitro/docs/examples/import-alias.md +100 -0
- package/skills/nitro/docs/examples/index.md +3 -0
- package/skills/nitro/docs/examples/middleware.md +91 -0
- package/skills/nitro/docs/examples/mono-jsx.md +68 -0
- package/skills/nitro/docs/examples/nano-jsx.md +70 -0
- package/skills/nitro/docs/examples/plugins.md +91 -0
- package/skills/nitro/docs/examples/renderer.md +113 -0
- package/skills/nitro/docs/examples/runtime-config.md +97 -0
- package/skills/nitro/docs/examples/server-fetch.md +87 -0
- package/skills/nitro/docs/examples/shiki.md +198 -0
- package/skills/nitro/docs/examples/virtual-routes.md +74 -0
- package/skills/nitro/docs/examples/vite-nitro-plugin.md +79 -0
- package/skills/nitro/docs/examples/vite-rsc.md +1041 -0
- package/skills/nitro/docs/examples/vite-ssr-html.md +217 -0
- package/skills/nitro/docs/examples/vite-ssr-preact.md +247 -0
- package/skills/nitro/docs/examples/vite-ssr-react.md +226 -0
- package/skills/nitro/docs/examples/vite-ssr-solid.md +256 -0
- package/skills/nitro/docs/examples/vite-ssr-tsr-react.md +442 -0
- package/skills/nitro/docs/examples/vite-ssr-tss-react.md +444 -0
- package/skills/nitro/docs/examples/vite-ssr-vue-router.md +616 -0
- package/skills/nitro/docs/examples/vite-trpc.md +335 -0
- package/skills/nitro/docs/examples/websocket.md +282 -0
- package/skills/nitro/docs/index.md +121 -0
|
@@ -0,0 +1,185 @@
|
|
|
1
|
+
> Nitro provides a built-in and lightweight SQL database layer.
|
|
2
|
+
|
|
3
|
+
The default database connection is **preconfigured** with [SQLite](https://db0.unjs.io/connectors/sqlite) and works out of the box for development mode and any Node.js compatible production deployments. By default, data will be stored in `.data/db.sqlite`.
|
|
4
|
+
|
|
5
|
+
<read-more></read-more>
|
|
6
|
+
|
|
7
|
+
> [!IMPORTANT]
|
|
8
|
+
> Database support is currently experimental.
|
|
9
|
+
> Refer to the [db0 issues](https://github.com/unjs/db0/issues) for status and bug report.
|
|
10
|
+
|
|
11
|
+
In order to enable database layer you need to enable experimental feature flag.
|
|
12
|
+
|
|
13
|
+
```ts [nitro.config.ts]
|
|
14
|
+
import { defineNitroConfig } from "nitro/config";
|
|
15
|
+
|
|
16
|
+
export default defineNitroConfig({
|
|
17
|
+
experimental: {
|
|
18
|
+
database: true
|
|
19
|
+
}
|
|
20
|
+
})
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
> [!TIP]
|
|
24
|
+
> You can change default connection or define more connections to any of the [supported databases](https://db0.unjs.io/connectors/sqlite).
|
|
25
|
+
|
|
26
|
+
> [!TIP]
|
|
27
|
+
> You can integrate database instance to any of the [supported ORMs](https://db0.unjs.io/integrations).
|
|
28
|
+
|
|
29
|
+
## Usage
|
|
30
|
+
|
|
31
|
+
```ts [server.ts]
|
|
32
|
+
import { defineHandler } from "nitro";
|
|
33
|
+
import { useDatabase } from "nitro/database";
|
|
34
|
+
|
|
35
|
+
export default defineHandler(async () => {
|
|
36
|
+
const db = useDatabase();
|
|
37
|
+
|
|
38
|
+
// Create users table
|
|
39
|
+
await db.sql`DROP TABLE IF EXISTS users`;
|
|
40
|
+
await db.sql`CREATE TABLE IF NOT EXISTS users ("id" TEXT PRIMARY KEY, "firstName" TEXT, "lastName" TEXT, "email" TEXT)`;
|
|
41
|
+
|
|
42
|
+
// Add a new user
|
|
43
|
+
const userId = String(Math.round(Math.random() * 10_000));
|
|
44
|
+
await db.sql`INSERT INTO users VALUES (${userId}, 'John', 'Doe', '')`;
|
|
45
|
+
|
|
46
|
+
// Query for users
|
|
47
|
+
const { rows } = await db.sql`SELECT * FROM users WHERE id = ${userId}`;
|
|
48
|
+
|
|
49
|
+
return {
|
|
50
|
+
rows,
|
|
51
|
+
};
|
|
52
|
+
});
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
### `useDatabase`
|
|
56
|
+
|
|
57
|
+
Use `useDatabase` to get a database instance. It accepts an optional connection name (defaults to `"default"`).
|
|
58
|
+
|
|
59
|
+
```ts
|
|
60
|
+
import { useDatabase } from "nitro/database";
|
|
61
|
+
|
|
62
|
+
// Use the default connection
|
|
63
|
+
const db = useDatabase();
|
|
64
|
+
|
|
65
|
+
// Use a named connection
|
|
66
|
+
const usersDb = useDatabase("users");
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
> [!NOTE]
|
|
70
|
+
> When `experimental.database` is enabled, `useDatabase` is auto-imported and available without an explicit import statement.
|
|
71
|
+
|
|
72
|
+
Database instances are created lazily on first use and cached for subsequent calls with the same connection name. If a connection name is not configured, an error will be thrown.
|
|
73
|
+
|
|
74
|
+
### `db.sql`
|
|
75
|
+
|
|
76
|
+
Execute SQL queries using tagged template literals with automatic parameter binding:
|
|
77
|
+
|
|
78
|
+
```ts
|
|
79
|
+
const db = useDatabase();
|
|
80
|
+
|
|
81
|
+
// Insert with parameterized values (safe from SQL injection)
|
|
82
|
+
const id = "1001";
|
|
83
|
+
await db.sql`INSERT INTO users VALUES (${id}, 'John', 'Doe', 'john@example.com')`;
|
|
84
|
+
|
|
85
|
+
// Query with parameters
|
|
86
|
+
const { rows } = await db.sql`SELECT * FROM users WHERE id = ${id}`;
|
|
87
|
+
|
|
88
|
+
// The result includes rows, changes count, and last insert ID
|
|
89
|
+
const result = await db.sql`INSERT INTO posts (title) VALUES (${"Hello"})`;
|
|
90
|
+
// result.rows, result.changes, result.lastInsertRowid
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
### `db.exec`
|
|
94
|
+
|
|
95
|
+
Execute a raw SQL string directly:
|
|
96
|
+
|
|
97
|
+
```ts
|
|
98
|
+
const db = useDatabase();
|
|
99
|
+
|
|
100
|
+
await db.exec("CREATE TABLE IF NOT EXISTS users (id TEXT PRIMARY KEY, name TEXT)");
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
### `db.prepare`
|
|
104
|
+
|
|
105
|
+
Prepare an SQL statement for repeated execution:
|
|
106
|
+
|
|
107
|
+
```ts
|
|
108
|
+
const db = useDatabase();
|
|
109
|
+
|
|
110
|
+
const stmt = db.prepare("SELECT * FROM users WHERE id = ?");
|
|
111
|
+
const result = await stmt.bind("1001").all();
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
## Configuration
|
|
115
|
+
|
|
116
|
+
You can configure database connections using `database` config:
|
|
117
|
+
|
|
118
|
+
```ts [nitro.config.ts]
|
|
119
|
+
import { defineNitroConfig } from "nitro/config";
|
|
120
|
+
|
|
121
|
+
export default defineNitroConfig({
|
|
122
|
+
database: {
|
|
123
|
+
default: {
|
|
124
|
+
connector: "sqlite",
|
|
125
|
+
options: { name: "db" }
|
|
126
|
+
},
|
|
127
|
+
users: {
|
|
128
|
+
connector: "postgresql",
|
|
129
|
+
options: {
|
|
130
|
+
url: "postgresql://username:password@hostname:port/database_name"
|
|
131
|
+
},
|
|
132
|
+
},
|
|
133
|
+
},
|
|
134
|
+
});
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
### Development Database
|
|
138
|
+
|
|
139
|
+
Use the `devDatabase` config to override the database configuration **only for development mode**. This is useful for using a local SQLite database during development while targeting a different database in production.
|
|
140
|
+
|
|
141
|
+
```ts [nitro.config.ts]
|
|
142
|
+
import { defineNitroConfig } from "nitro/config";
|
|
143
|
+
|
|
144
|
+
export default defineNitroConfig({
|
|
145
|
+
database: {
|
|
146
|
+
default: {
|
|
147
|
+
connector: "postgresql",
|
|
148
|
+
options: {
|
|
149
|
+
url: "postgresql://username:password@hostname:port/database_name"
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
},
|
|
153
|
+
devDatabase: {
|
|
154
|
+
default: {
|
|
155
|
+
connector: "sqlite",
|
|
156
|
+
options: { name: "dev-db" }
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
});
|
|
160
|
+
```
|
|
161
|
+
|
|
162
|
+
> [!TIP]
|
|
163
|
+
> When `experimental.database` is enabled and no `database` or `devDatabase` config is provided, Nitro automatically configures a default SQLite connection. In development mode, data is stored relative to the project root directory. In Node.js production, it uses the default SQLite path.
|
|
164
|
+
|
|
165
|
+
## Connectors
|
|
166
|
+
|
|
167
|
+
Nitro supports all [db0 connectors](https://db0.unjs.io/connectors). The `connector` field in the database config accepts any of the following values:
|
|
168
|
+
|
|
169
|
+
| Connector | Description |
|
|
170
|
+
| --- | --- |
|
|
171
|
+
| `sqlite` | Node.js built-in SQLite (alias for `node-sqlite`) |
|
|
172
|
+
| `node-sqlite` | Node.js built-in SQLite |
|
|
173
|
+
| `better-sqlite3` | [better-sqlite3](https://github.com/WiseLibs/better-sqlite3) |
|
|
174
|
+
| `sqlite3` | [sqlite3](https://github.com/TryGhost/node-sqlite3) |
|
|
175
|
+
| `bun` / `bun-sqlite` | Bun built-in SQLite |
|
|
176
|
+
| `libsql` / `libsql-node` | [libSQL](https://github.com/tursodatabase/libsql) (Node.js) |
|
|
177
|
+
| `libsql-http` | libSQL over HTTP |
|
|
178
|
+
| `libsql-web` | libSQL for web environments |
|
|
179
|
+
| `postgresql` | [PostgreSQL](https://github.com/porsager/postgres) |
|
|
180
|
+
| `mysql2` | [MySQL](https://github.com/sidorares/node-mysql2) |
|
|
181
|
+
| `pglite` | [PGlite](https://github.com/electric-sql/pglite) (embedded PostgreSQL) |
|
|
182
|
+
| `planetscale` | [PlanetScale](https://github.com/planetscale/database-js) serverless |
|
|
183
|
+
| `cloudflare-d1` | [Cloudflare D1](https://developers.cloudflare.com/d1/) |
|
|
184
|
+
| `cloudflare-hyperdrive-mysql` | Cloudflare Hyperdrive with MySQL |
|
|
185
|
+
| `cloudflare-hyperdrive-postgresql` | Cloudflare Hyperdrive with PostgreSQL |
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
# Introduction
|
|
2
|
+
|
|
3
|
+
> Nitro is a full-stack server framework, compatible with any runtime and any deployment target.
|
|
4
|
+
|
|
5
|
+
Nitro gives you a production-ready server with filesystem routing, code-splitting, and built-in support for storage, caching, and databases — all runtime-agnostic and deployable anywhere.
|
|
6
|
+
|
|
7
|
+
## What is Nitro?
|
|
8
|
+
|
|
9
|
+
Create server and API routes inside the `routes/` directory. Each file maps directly to a URL path, and Nitro handles the rest — routing, code-splitting, and optimized builds.
|
|
10
|
+
|
|
11
|
+
You can also take full control of the server entry by creating a `server.ts` file. Nitro’s high-level, runtime-agnostic approach lets you use any HTTP library, such as [Elysia](https://elysiajs.com/), [h3](https://h3.dev), or [Hono](https://hono.dev).
|
|
12
|
+
|
|
13
|
+
### Performance
|
|
14
|
+
|
|
15
|
+
Nitro compiles your routes at build time, removing the need for a runtime router. Only the code required to handle each incoming request is loaded and executed. This makes it ideal for serverless hosting, with near-0ms boot time regardless of project size.
|
|
16
|
+
|
|
17
|
+
### Deploy Anywhere
|
|
18
|
+
|
|
19
|
+
Build your server into an optimized `.output/` folder compatible with Node.js, Bun, Deno, and many hosting platforms without any configuration — Cloudflare Workers, Netlify, Vercel, and more. Take advantage of platform features like ESR, ISR, and SWR without changing a single line of code.
|
|
20
|
+
|
|
21
|
+
### Server-Side Rendering
|
|
22
|
+
|
|
23
|
+
Render HTML with your favorite templating engine, or use component libraries such as React, Vue, or Svelte directly on the server. Go full universal rendering with client-side hydration. Nitro provides the foundation and a progressive approach to reach your goals.
|
|
24
|
+
|
|
25
|
+
### Storage
|
|
26
|
+
|
|
27
|
+
Nitro includes a runtime-agnostic key-value storage layer out of the box. It uses in-memory storage by default, but you can connect more than 20 different drivers (FS, Redis, S3, etc.), attach them to different namespaces, and swap them without changing your code.
|
|
28
|
+
|
|
29
|
+
### Caching
|
|
30
|
+
|
|
31
|
+
Nitro supports caching for both server routes and server functions, backed directly by the server storage (via the `cache` namespace).
|
|
32
|
+
|
|
33
|
+
### Database
|
|
34
|
+
|
|
35
|
+
Nitro also includes a built-in SQL database. It defaults to SQLite, but you can connect to and query more than 10 databases (Postgres, MySQL, PGLite, etc.) using the same API.
|
|
36
|
+
|
|
37
|
+
### Meta-Framework Foundation
|
|
38
|
+
|
|
39
|
+
Nitro can be used as the foundation for building your own meta-framework. Popular frameworks such as Nuxt, SolidStart, and TanStack Start fully or partially leverage Nitro.
|
|
40
|
+
|
|
41
|
+
## Vite Integration
|
|
42
|
+
|
|
43
|
+
Nitro integrates seamlessly with [Vite](https://vite.dev) as a plugin. If you’re building a frontend application with Vite, adding Nitro gives you API routes, server-side rendering, and a full production server — all built together with `vite build`.
|
|
44
|
+
|
|
45
|
+
```ts [vite.config.ts]
|
|
46
|
+
import { defineConfig } from "vite";
|
|
47
|
+
import { nitro } from "nitro/vite";
|
|
48
|
+
|
|
49
|
+
export default defineConfig({
|
|
50
|
+
plugins: [nitro()],
|
|
51
|
+
});
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
With Nitro, `vite build` produces an optimized `.output/` folder containing both your frontend and backend — ready to deploy anywhere.
|
|
55
|
+
|
|
56
|
+
Ready to give it a try? Jump into the [quick start](/docs/quick-start).
|
|
@@ -0,0 +1,204 @@
|
|
|
1
|
+
# Lifecycle
|
|
2
|
+
|
|
3
|
+
> Understand how Nitro runs and serves incoming requests to your application.
|
|
4
|
+
|
|
5
|
+
## Request lifecycle
|
|
6
|
+
|
|
7
|
+
A request can be intercepted and terminated (with or without a response) from any of these layers, in this order:
|
|
8
|
+
|
|
9
|
+
<steps>
|
|
10
|
+
|
|
11
|
+
### `request` hook
|
|
12
|
+
|
|
13
|
+
The `request` hook is the first code that runs for every incoming request. It is registered via a [server plugin](/docs/plugins):
|
|
14
|
+
|
|
15
|
+
```ts [plugins/request-hook.ts]
|
|
16
|
+
import { definePlugin } from "nitro";
|
|
17
|
+
|
|
18
|
+
export default definePlugin((nitroApp) => {
|
|
19
|
+
nitroApp.hooks.hook("request", (event) => {
|
|
20
|
+
console.log(`Incoming request on ${event.path}`);
|
|
21
|
+
});
|
|
22
|
+
});
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
<note>
|
|
26
|
+
|
|
27
|
+
Errors thrown inside the `request` hook are captured by the [`error` hook](#error-handling) and do not terminate the request pipeline.
|
|
28
|
+
</note>
|
|
29
|
+
|
|
30
|
+
### Static assets
|
|
31
|
+
|
|
32
|
+
When static asset serving is enabled (the default for most presets), Nitro checks if the request matches a file in the `public/` directory **before** any other middleware or route handler runs.
|
|
33
|
+
|
|
34
|
+
If a match is found, the static file is served immediately with appropriate `Content-Type`, `ETag`, `Last-Modified`, and `Cache-Control` headers. The request is terminated and no further middleware or routes are executed.
|
|
35
|
+
|
|
36
|
+
Static assets also support content negotiation for pre-compressed files (gzip, brotli, zstd) via the `Accept-Encoding` header.
|
|
37
|
+
|
|
38
|
+
### Route rules
|
|
39
|
+
|
|
40
|
+
The matching route rules defined in the Nitro config will execute. Route rules run as middleware so most of them alter the response without terminating it (for instance, adding a header or setting a cache policy).
|
|
41
|
+
|
|
42
|
+
```ts [nitro.config.ts]
|
|
43
|
+
import { defineNitroConfig } from "nitro/config";
|
|
44
|
+
|
|
45
|
+
export default defineNitroConfig({
|
|
46
|
+
routeRules: {
|
|
47
|
+
'/**': { headers: { 'x-nitro': 'first' } }
|
|
48
|
+
}
|
|
49
|
+
})
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
<read-more></read-more>
|
|
53
|
+
|
|
54
|
+
### Global middleware
|
|
55
|
+
|
|
56
|
+
Any global middleware defined in the `middleware/` directory will be run:
|
|
57
|
+
|
|
58
|
+
```ts [middleware/info.ts]
|
|
59
|
+
import { defineHandler } from "nitro";
|
|
60
|
+
|
|
61
|
+
export default defineHandler((event) => {
|
|
62
|
+
event.context.info = { name: "Nitro" };
|
|
63
|
+
});
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
<warning>
|
|
67
|
+
|
|
68
|
+
Returning from a middleware will close the request and should be avoided when possible.
|
|
69
|
+
</warning>
|
|
70
|
+
|
|
71
|
+
<read-more>
|
|
72
|
+
|
|
73
|
+
Learn more about Nitro middleware.
|
|
74
|
+
</read-more>
|
|
75
|
+
|
|
76
|
+
### Routed middleware
|
|
77
|
+
|
|
78
|
+
Middleware that targets a specific route pattern (defined with a `route` in `middleware/`) runs after global middleware but before the matched route handler.
|
|
79
|
+
|
|
80
|
+
### Routes
|
|
81
|
+
|
|
82
|
+
Nitro will look at defined routes in the `routes/` folder to match the incoming request.
|
|
83
|
+
|
|
84
|
+
```ts [routes/api/hello.ts]
|
|
85
|
+
export default (event) => ({ world: true })
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
<read-more>
|
|
89
|
+
|
|
90
|
+
Learn more about Nitro file-system routing.
|
|
91
|
+
</read-more>
|
|
92
|
+
|
|
93
|
+
If serverEntry is defined it will catch all requests not matching any other route acting as `/**` route handler.
|
|
94
|
+
|
|
95
|
+
```ts [server.ts]
|
|
96
|
+
import { defineHandler } from "nitro";
|
|
97
|
+
|
|
98
|
+
export default defineHandler((event) => {
|
|
99
|
+
if (event.path === "/") {
|
|
100
|
+
return "Home page";
|
|
101
|
+
}
|
|
102
|
+
});
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
<read-more>
|
|
106
|
+
|
|
107
|
+
Learn more about Nitro server entry.
|
|
108
|
+
</read-more>
|
|
109
|
+
|
|
110
|
+
### Renderer
|
|
111
|
+
|
|
112
|
+
If no route is matched, Nitro will look for a renderer handler (defined or auto-detected) to handle the request.
|
|
113
|
+
|
|
114
|
+
<read-more>
|
|
115
|
+
|
|
116
|
+
Learn more about Nitro renderer.
|
|
117
|
+
</read-more>
|
|
118
|
+
|
|
119
|
+
### `response` hook
|
|
120
|
+
|
|
121
|
+
After the response is created (from any of the layers above), the `response` hook runs. This hook receives the final `Response` object and the event, and can be used to inspect or modify response headers:
|
|
122
|
+
|
|
123
|
+
```ts [plugins/response-hook.ts]
|
|
124
|
+
import { definePlugin } from "nitro";
|
|
125
|
+
|
|
126
|
+
export default definePlugin((nitroApp) => {
|
|
127
|
+
nitroApp.hooks.hook("response", (res, event) => {
|
|
128
|
+
console.log(`Response ${res.status} for ${event.path}`);
|
|
129
|
+
});
|
|
130
|
+
});
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
<note>
|
|
134
|
+
|
|
135
|
+
The `response` hook runs for every response, including static assets, middleware-terminated requests, and error responses.
|
|
136
|
+
</note>
|
|
137
|
+
</steps>
|
|
138
|
+
|
|
139
|
+
## Error handling
|
|
140
|
+
|
|
141
|
+
When an error occurs at any point in the request lifecycle, Nitro:
|
|
142
|
+
|
|
143
|
+
1. Calls the `error` hook with the error and context (including the event and source tags).
|
|
144
|
+
2. Passes the error to the **error handler** which converts it into an HTTP response.
|
|
145
|
+
|
|
146
|
+
```ts [plugins/errors.ts]
|
|
147
|
+
import { definePlugin } from "nitro";
|
|
148
|
+
|
|
149
|
+
export default definePlugin((nitroApp) => {
|
|
150
|
+
nitroApp.hooks.hook("error", (error, context) => {
|
|
151
|
+
console.error("Captured error:", error);
|
|
152
|
+
// context.event - the H3 event (if available)
|
|
153
|
+
// context.tags - error source tags like "request", "response", "plugin"
|
|
154
|
+
});
|
|
155
|
+
});
|
|
156
|
+
```
|
|
157
|
+
Errors are also tracked per-request in `event.req.context.nitro.errors` for inspection in later hooks.
|
|
158
|
+
|
|
159
|
+
You can provide a custom error handler in the Nitro config to control error response formatting:
|
|
160
|
+
|
|
161
|
+
```ts [nitro.config.ts]
|
|
162
|
+
import { defineNitroConfig } from "nitro/config";
|
|
163
|
+
|
|
164
|
+
export default defineNitroConfig({
|
|
165
|
+
errorHandler: "~/error",
|
|
166
|
+
})
|
|
167
|
+
```
|
|
168
|
+
|
|
169
|
+
Additionally, unhandled promise rejections and uncaught exceptions at the process level are automatically captured into the `error` hook with the tags `"unhandledRejection"` and `"uncaughtException"`.
|
|
170
|
+
|
|
171
|
+
## Server shutdown
|
|
172
|
+
|
|
173
|
+
When the Nitro server is shutting down, the `close` hook is called. Use this to clean up resources such as database connections, timers, or external service handles:
|
|
174
|
+
|
|
175
|
+
```ts [plugins/cleanup.ts]
|
|
176
|
+
import { definePlugin } from "nitro";
|
|
177
|
+
|
|
178
|
+
export default definePlugin((nitroApp) => {
|
|
179
|
+
nitroApp.hooks.hook("close", async () => {
|
|
180
|
+
// Clean up resources
|
|
181
|
+
});
|
|
182
|
+
});
|
|
183
|
+
```
|
|
184
|
+
|
|
185
|
+
## Hooks reference
|
|
186
|
+
|
|
187
|
+
All runtime hooks are registered through [server plugins](/docs/plugins) using `nitroApp.hooks.hook()`.
|
|
188
|
+
|
|
189
|
+
| Hook | Signature | When it runs |
|
|
190
|
+
| --- | --- | --- |
|
|
191
|
+
| `request` | `(event: HTTPEvent) => void \| Promise<void>` | Start of each request, before routing. |
|
|
192
|
+
| `response` | `(res: Response, event: HTTPEvent) => void \| Promise<void>` | After the response is created, before it is sent. |
|
|
193
|
+
| `error` | `(error: Error, context: { event?, tags? }) => void` | When any error is captured during the lifecycle. |
|
|
194
|
+
| `close` | `() => void` | When the Nitro server is shutting down. |
|
|
195
|
+
|
|
196
|
+
<note>
|
|
197
|
+
|
|
198
|
+
The `NitroRuntimeHooks` interface is augmentable. Deployment presets (such as Cloudflare) can extend it with platform-specific hooks.
|
|
199
|
+
</note>
|
|
200
|
+
|
|
201
|
+
<read-more>
|
|
202
|
+
|
|
203
|
+
Learn more about Nitro plugins and hook usage examples.
|
|
204
|
+
</read-more>
|
|
@@ -0,0 +1,215 @@
|
|
|
1
|
+
# Migration Guide
|
|
2
|
+
|
|
3
|
+
> [!NOTE]
|
|
4
|
+
> This is a living document for migrating from Nitro 2 to 3. Please check it regularly while using the beta version.
|
|
5
|
+
|
|
6
|
+
Nitro v3 introduces intentional backward-incompatible changes. This guide helps you migrate from Nitro v2.
|
|
7
|
+
|
|
8
|
+
## `nitropack` is renamed to `nitro`
|
|
9
|
+
|
|
10
|
+
The NPM package [nitropack](https://www.npmjs.com/package/nitropack) (v2) has been renamed to [nitro](https://www.npmjs.com/package/nitro) (v3).
|
|
11
|
+
|
|
12
|
+
**Migration:** Update the `nitropack` dependency to `nitro` in `package.json`:
|
|
13
|
+
|
|
14
|
+
```diff [release channel]
|
|
15
|
+
{
|
|
16
|
+
"dependencies": {
|
|
17
|
+
-- "nitropack": "latest"
|
|
18
|
+
++ "nitro": "latest"
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
```diff [nightly channel]
|
|
24
|
+
{
|
|
25
|
+
"dependencies": {
|
|
26
|
+
-- "nitropack": "latest"
|
|
27
|
+
++ "nitro": "npm:nitro-nightly"
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
**Migration:** Search your codebase and rename all instances of nitropack to nitro:
|
|
33
|
+
|
|
34
|
+
```diff
|
|
35
|
+
-- import { defineNitroConfig } from "nitropack/config"
|
|
36
|
+
++ import { defineNitroConfig } from "nitro/config"
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
## nitro/runtime
|
|
40
|
+
|
|
41
|
+
Runtime utils had been moved to individual `nitro/*` subpath exports. Refer to docs for usage.
|
|
42
|
+
|
|
43
|
+
```diff
|
|
44
|
+
-- import { useStorage } from "nitropack/runtime/storage"
|
|
45
|
+
++ import { useStorage } from "nitro/storage"
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
## Minimum Supported Node.js Version: 20
|
|
49
|
+
|
|
50
|
+
Nitro now requires a minimum Node.js version of 20, as Node.js 18 reaches end-of-life in [April 2025](https://nodejs.org/en/about/previous-releases).
|
|
51
|
+
|
|
52
|
+
Please upgrade to the [latest LTS](https://nodejs.org/en/download) version (>= 20).
|
|
53
|
+
|
|
54
|
+
**Migration:**
|
|
55
|
+
|
|
56
|
+
- Check your local Node.js version using `node --version` and update if necessary.
|
|
57
|
+
- If you use a CI/CD system for deployment, ensure that your pipeline is running Node.js 20 or higher.
|
|
58
|
+
- If your hosting provider manages the Node.js runtime, make sure it's set to version 20, 22, or later.
|
|
59
|
+
|
|
60
|
+
## Type Imports
|
|
61
|
+
Nitro types are now only exported from `nitro/types`.
|
|
62
|
+
|
|
63
|
+
**Migration:** Import types from nitro/types instead of nitro:
|
|
64
|
+
|
|
65
|
+
```diff
|
|
66
|
+
-- import { NitroRuntimeConfig } from "nitropack"
|
|
67
|
+
++ import { NitroRuntimeConfig } from "nitro/types"
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
## App Config Support Removed
|
|
71
|
+
|
|
72
|
+
Nitro v2 supported a bundled app config that allowed defining configurations in `app.config.ts` and accessing them at runtime via `useAppConfig()`.
|
|
73
|
+
|
|
74
|
+
This feature had been removed.
|
|
75
|
+
|
|
76
|
+
**Migration:**
|
|
77
|
+
|
|
78
|
+
Use a regular `.ts` file in your server directory and import it directly.
|
|
79
|
+
|
|
80
|
+
## Preset updates
|
|
81
|
+
|
|
82
|
+
Nitro presets have been updated for the latest compatibility.
|
|
83
|
+
|
|
84
|
+
Some (legacy) presets have been removed or renamed.
|
|
85
|
+
|
|
86
|
+
| Old Preset | New Preset |
|
|
87
|
+
| --- | --- |
|
|
88
|
+
| `node` | `node_middleware` (export changed to `middleware`) |
|
|
89
|
+
| `cloudflare`, `cloudflare_worker`, `cloudflare_module_legacy` | `cloudflare_module` |
|
|
90
|
+
| `deno-server-legacy` | `deno_server` with Deno v2 |
|
|
91
|
+
| `netlify-builder` | `netlify` or `netlify_edge` |
|
|
92
|
+
| `vercel-edge` | `vercel` with Fluid compute enabled |
|
|
93
|
+
| `azure`, `azure_functions` | `azure_swa` |
|
|
94
|
+
| `firebase` | `firebase_app_hosting` |
|
|
95
|
+
| `iis` | `iis_handler` |
|
|
96
|
+
| `deno` | `deno_deploy` |
|
|
97
|
+
| `edgio` | Discontinued |
|
|
98
|
+
| `cli` | Removed due to lack of use |
|
|
99
|
+
| `service_worker` | Removed due to instability |
|
|
100
|
+
|
|
101
|
+
## Cloudflare Bindings Access
|
|
102
|
+
|
|
103
|
+
In Nitro v2, Cloudflare environment variables and bindings were accessible via `event.context.cloudflare.env`.
|
|
104
|
+
|
|
105
|
+
In Nitro v3, the Cloudflare preset uses [srvx](https://srvx.unjs.io/) as the underlying server layer. The Cloudflare runtime context is now attached to the request's runtime object instead of the event context.
|
|
106
|
+
|
|
107
|
+
**Migration:**
|
|
108
|
+
|
|
109
|
+
```diff
|
|
110
|
+
-- const { cloudflare } = event.context
|
|
111
|
+
-- const binding = cloudflare.env.MY_BINDING
|
|
112
|
+
++ const { env } = event.req.runtime.cloudflare
|
|
113
|
+
++ const binding = env.MY_BINDING
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
::
|
|
117
|
+
|
|
118
|
+
## Changed nitro subpath imports
|
|
119
|
+
|
|
120
|
+
Nitro v2 introduced multiple subpath exports, some of which have been removed or updated:
|
|
121
|
+
|
|
122
|
+
- `nitro/rollup`, `nitropack/core` (use `nitro/builder`)
|
|
123
|
+
- `nitropack/runtime/*` (use `nitro/*`)
|
|
124
|
+
- `nitropack/kit` (removed)
|
|
125
|
+
- `nitropack/presets` (removed)
|
|
126
|
+
An experimental `nitropack/kit` was introduced but has now been removed. A standalone Nitro Kit package may be introduced in the future with clearer objectives.
|
|
127
|
+
|
|
128
|
+
**Migration:**
|
|
129
|
+
|
|
130
|
+
- Use `NitroModule` from `nitro/types` instead of `defineNitroModule` from the kit.
|
|
131
|
+
- Prefer built-in Nitro presets (external presets are only for evaluation purposes).
|
|
132
|
+
|
|
133
|
+
## H3 v2
|
|
134
|
+
Nitro v3 upgrades to [H3 v2](https://h3.dev), which includes API changes. All H3 utilities are imported from `nitro/h3`.
|
|
135
|
+
|
|
136
|
+
### Web Standards
|
|
137
|
+
|
|
138
|
+
H3 v2 is rewritten based on web standard primitives ([`URL`](https://developer.mozilla.org/en-US/docs/Web/API/URL), [`Headers`](https://developer.mozilla.org/en-US/docs/Web/API/Headers), [`Request`](https://developer.mozilla.org/en-US/docs/Web/API/Request), and [`Response`](https://developer.mozilla.org/en-US/docs/Web/API/Response)).
|
|
139
|
+
|
|
140
|
+
Access to `event.node.{req,res}` is only available in Node.js runtime. `event.web` is renamed to `event.req` (instance of web [`Request`](https://developer.mozilla.org/en-US/docs/Web/API/Request)).
|
|
141
|
+
|
|
142
|
+
### Response Handling
|
|
143
|
+
|
|
144
|
+
You should always explicitly **return** the response body or **throw** an error:
|
|
145
|
+
|
|
146
|
+
```diff
|
|
147
|
+
-- import { send, sendRedirect, sendStream } from "nitro/h3"
|
|
148
|
+
-- send(event, value)
|
|
149
|
+
-- sendStream(event, stream)
|
|
150
|
+
-- sendRedirect(event, location, code)
|
|
151
|
+
++ import { redirect } from "nitro/h3"
|
|
152
|
+
++ return value
|
|
153
|
+
++ return stream
|
|
154
|
+
++ return redirect(event, location, code)
|
|
155
|
+
```
|
|
156
|
+
|
|
157
|
+
Other changes:
|
|
158
|
+
|
|
159
|
+
- `sendError(event, error)` → `throw createError(error)`
|
|
160
|
+
- `sendNoContent(event)` → `return noContent(event)`
|
|
161
|
+
- `sendProxy(event, target)` → `return proxy(event, target)`
|
|
162
|
+
|
|
163
|
+
### Request Body
|
|
164
|
+
Most body utilities can be replaced with native `event.req` methods:
|
|
165
|
+
|
|
166
|
+
```diff
|
|
167
|
+
-- import { readBody, readRawBody, readFormData } from "nitro/h3"
|
|
168
|
+
++ // Use native Request methods
|
|
169
|
+
++ const json = await event.req.json()
|
|
170
|
+
++ const text = await event.req.text()
|
|
171
|
+
++ const formData = await event.req.formData()
|
|
172
|
+
++ const stream = event.req.body
|
|
173
|
+
```
|
|
174
|
+
|
|
175
|
+
### Headers
|
|
176
|
+
|
|
177
|
+
H3 now uses standard web [`Headers`](https://developer.mozilla.org/en-US/docs/Web/API/Headers). Header values are always plain `string` (no `null`, `undefined`, or `string[]`).
|
|
178
|
+
|
|
179
|
+
```diff
|
|
180
|
+
-- import { getHeader, setHeader, getResponseStatus } from "nitro/h3"
|
|
181
|
+
-- getHeader(event, "x-foo")
|
|
182
|
+
-- setHeader(event, "x-foo", "bar")
|
|
183
|
+
++ event.req.headers.get("x-foo")
|
|
184
|
+
++ event.res.headers.set("x-foo", "bar")
|
|
185
|
+
++ event.res.status // instead of getResponseStatus(event)
|
|
186
|
+
```
|
|
187
|
+
|
|
188
|
+
### Handler Utils
|
|
189
|
+
|
|
190
|
+
```diff
|
|
191
|
+
-- import { eventHandler, defineEventHandler } from "nitro/h3"
|
|
192
|
+
++ import { defineHandler } from "nitro"
|
|
193
|
+
```
|
|
194
|
+
|
|
195
|
+
- `lazyEventHandler` → `defineLazyEventHandler`
|
|
196
|
+
- `useBase` → `withBase`
|
|
197
|
+
|
|
198
|
+
### Error Utils
|
|
199
|
+
|
|
200
|
+
```diff
|
|
201
|
+
-- import { createError, isError } from "nitro/h3"
|
|
202
|
+
++ import { HTTPError } from "nitro"
|
|
203
|
+
++ throw new HTTPError({ status: 404, message: "Not found" })
|
|
204
|
+
++ HTTPError.isError(error)
|
|
205
|
+
```
|
|
206
|
+
|
|
207
|
+
### Node.js Utils
|
|
208
|
+
|
|
209
|
+
```diff
|
|
210
|
+
-- import { defineNodeListener, fromNodeMiddleware, toNodeListener } from "nitro/h3"
|
|
211
|
+
++ import { defineNodeHandler, fromNodeHandler, toNodeHandler } from "nitro/h3"
|
|
212
|
+
```
|
|
213
|
+
|
|
214
|
+
## Optional Hooks
|
|
215
|
+
If you were using `useNitroApp().hooks` outside of Nitro plugins before, it might be undefined. Use new `useNitroHooks()` to guarantee having an instance.
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
# Nightly Channel
|
|
2
|
+
|
|
3
|
+
> Nitro has a nightly release channel that automatically releases for every commit to `main` branch to try latest changes.
|
|
4
|
+
|
|
5
|
+
You can opt-in to the nightly release channel by updating your `package.json`:
|
|
6
|
+
|
|
7
|
+
```json
|
|
8
|
+
{
|
|
9
|
+
"devDependencies": {
|
|
10
|
+
"nitro": "npm:nitro-nightly@latest"
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
Remove the lockfile (`package-lock.json`, `yarn.lock`, `pnpm-lock.yaml`, `bun.lock`, or `bun.lockb`) and reinstall the dependencies.
|
|
16
|
+
|
|
17
|
+
<important>
|
|
18
|
+
|
|
19
|
+
When using **Bun as package manager** in a mono-repo, you need to make sure nitro package is properly hoisted.
|
|
20
|
+
|
|
21
|
+
```toml [bunfig.toml]
|
|
22
|
+
[install]
|
|
23
|
+
publicHoistPattern = ["nitro*"]
|
|
24
|
+
```
|
|
25
|
+
</important>
|
|
26
|
+
|
|
27
|
+
<important>
|
|
28
|
+
|
|
29
|
+
Avoid using `<npm|pnpm|yarn|bun|deno> install nitro-nightly`; it does not install correctly.
|
|
30
|
+
If you encounter issues, delete your `node_modules` and lock files, then follow the steps above.
|
|
31
|
+
</important>
|