@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,616 @@
|
|
|
1
|
+
# SSR with Vue Router
|
|
2
|
+
|
|
3
|
+
> Server-side rendering with Vue Router in Nitro using Vite.
|
|
4
|
+
|
|
5
|
+
<code-tree>
|
|
6
|
+
|
|
7
|
+
```json [package.json]
|
|
8
|
+
{
|
|
9
|
+
"type": "module",
|
|
10
|
+
"scripts": {
|
|
11
|
+
"build": "vite build",
|
|
12
|
+
"dev": "vite dev",
|
|
13
|
+
"preview": "vite preview"
|
|
14
|
+
},
|
|
15
|
+
"devDependencies": {
|
|
16
|
+
"@vitejs/plugin-vue": "^6.0.4",
|
|
17
|
+
"nitro": "latest",
|
|
18
|
+
"unhead": "^2.1.3",
|
|
19
|
+
"vite": "beta",
|
|
20
|
+
"vite-plugin-devtools-json": "^1.0.0",
|
|
21
|
+
"vue": "^3.5.27",
|
|
22
|
+
"vue-router": "^4.6.4"
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
```json [tsconfig.json]
|
|
28
|
+
{
|
|
29
|
+
"extends": "nitro/tsconfig"
|
|
30
|
+
}
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
```js [vite.config.mjs]
|
|
34
|
+
import vue from "@vitejs/plugin-vue";
|
|
35
|
+
import { defineConfig } from "vite";
|
|
36
|
+
import devtoolsJson from "vite-plugin-devtools-json";
|
|
37
|
+
import { nitro } from "nitro/vite";
|
|
38
|
+
|
|
39
|
+
export default defineConfig((_env) => ({
|
|
40
|
+
plugins: [patchVueExclude(vue(), /\?assets/), devtoolsJson(), nitro()],
|
|
41
|
+
environments: {
|
|
42
|
+
client: { build: { rollupOptions: { input: "./app/entry-client.ts" } } },
|
|
43
|
+
ssr: { build: { rollupOptions: { input: "./app/entry-server.ts" } } },
|
|
44
|
+
},
|
|
45
|
+
}));
|
|
46
|
+
|
|
47
|
+
// Workaround https://github.com/vitejs/vite-plugin-vue/issues/677
|
|
48
|
+
function patchVueExclude(plugin, exclude) {
|
|
49
|
+
const original = plugin.transform.handler;
|
|
50
|
+
plugin.transform.handler = function (...args) {
|
|
51
|
+
if (exclude.test(args[1])) return;
|
|
52
|
+
return original.call(this, ...args);
|
|
53
|
+
};
|
|
54
|
+
return plugin;
|
|
55
|
+
}
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
```vue [app/app.vue]
|
|
59
|
+
<script setup lang="ts">
|
|
60
|
+
import { RouterLink, RouterView } from "vue-router";
|
|
61
|
+
import "./styles.css";
|
|
62
|
+
</script>
|
|
63
|
+
|
|
64
|
+
<template>
|
|
65
|
+
<nav>
|
|
66
|
+
<ul>
|
|
67
|
+
<li>
|
|
68
|
+
<RouterLink to="/" exact-active-class="active">Home</RouterLink>
|
|
69
|
+
</li>
|
|
70
|
+
<li>
|
|
71
|
+
<RouterLink to="/about" active-class="active">About</RouterLink>
|
|
72
|
+
</li>
|
|
73
|
+
</ul>
|
|
74
|
+
</nav>
|
|
75
|
+
<RouterView />
|
|
76
|
+
</template>
|
|
77
|
+
|
|
78
|
+
<style scoped>
|
|
79
|
+
nav {
|
|
80
|
+
background: white;
|
|
81
|
+
box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
|
|
82
|
+
padding: 1rem;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
nav ul {
|
|
86
|
+
list-style: none;
|
|
87
|
+
margin: 0;
|
|
88
|
+
padding: 0;
|
|
89
|
+
display: flex;
|
|
90
|
+
gap: 2rem;
|
|
91
|
+
max-width: 800px;
|
|
92
|
+
margin: 0 auto;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
nav a {
|
|
96
|
+
color: #666;
|
|
97
|
+
text-decoration: none;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
nav a:hover {
|
|
101
|
+
color: #333;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
nav a.active {
|
|
105
|
+
color: #646cff;
|
|
106
|
+
}
|
|
107
|
+
</style>
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
```ts [app/entry-client.ts]
|
|
111
|
+
import { createSSRApp } from "vue";
|
|
112
|
+
import { RouterView, createRouter, createWebHistory } from "vue-router";
|
|
113
|
+
import { routes } from "./routes.ts";
|
|
114
|
+
|
|
115
|
+
async function main() {
|
|
116
|
+
const app = createSSRApp(RouterView);
|
|
117
|
+
const router = createRouter({ history: createWebHistory(), routes });
|
|
118
|
+
app.use(router);
|
|
119
|
+
|
|
120
|
+
await router.isReady();
|
|
121
|
+
app.mount("#root");
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
// eslint-disable-next-line unicorn/prefer-top-level-await
|
|
125
|
+
main();
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
```ts [app/entry-server.ts]
|
|
129
|
+
import { createSSRApp } from "vue";
|
|
130
|
+
import { renderToString } from "vue/server-renderer";
|
|
131
|
+
import { RouterView, createMemoryHistory, createRouter } from "vue-router";
|
|
132
|
+
import { createHead, transformHtmlTemplate } from "unhead/server";
|
|
133
|
+
|
|
134
|
+
import { routes } from "./routes.ts";
|
|
135
|
+
|
|
136
|
+
import clientAssets from "./entry-client.ts?assets=client";
|
|
137
|
+
|
|
138
|
+
async function handler(request: Request): Promise<Response> {
|
|
139
|
+
const app = createSSRApp(RouterView);
|
|
140
|
+
const router = createRouter({ history: createMemoryHistory(), routes });
|
|
141
|
+
app.use(router);
|
|
142
|
+
|
|
143
|
+
const url = new URL(request.url);
|
|
144
|
+
const href = url.href.slice(url.origin.length);
|
|
145
|
+
|
|
146
|
+
await router.push(href);
|
|
147
|
+
await router.isReady();
|
|
148
|
+
|
|
149
|
+
const assets = clientAssets.merge(
|
|
150
|
+
...(await Promise.all(
|
|
151
|
+
router.currentRoute.value.matched
|
|
152
|
+
.map((to) => to.meta.assets)
|
|
153
|
+
.filter(Boolean)
|
|
154
|
+
.map((fn) => (fn as any)().then((m: any) => m.default))
|
|
155
|
+
))
|
|
156
|
+
);
|
|
157
|
+
|
|
158
|
+
const head = createHead();
|
|
159
|
+
|
|
160
|
+
head.push({
|
|
161
|
+
link: [
|
|
162
|
+
...assets.css.map((attrs: any) => ({ rel: "stylesheet", ...attrs })),
|
|
163
|
+
...assets.js.map((attrs: any) => ({ rel: "modulepreload", ...attrs })),
|
|
164
|
+
],
|
|
165
|
+
script: [{ type: "module", src: clientAssets.entry }],
|
|
166
|
+
});
|
|
167
|
+
|
|
168
|
+
const renderedApp = await renderToString(app);
|
|
169
|
+
|
|
170
|
+
const html = await transformHtmlTemplate(head, htmlTemplate(renderedApp));
|
|
171
|
+
|
|
172
|
+
return new Response(html, {
|
|
173
|
+
headers: { "Content-Type": "text/html;charset=utf-8" },
|
|
174
|
+
});
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
function htmlTemplate(body: string): string {
|
|
178
|
+
return /* html */ `<!DOCTYPE html>
|
|
179
|
+
<html lang="en">
|
|
180
|
+
<head>
|
|
181
|
+
<meta charset="UTF-8" />
|
|
182
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
183
|
+
<title>Vue Router Custom Framework</title>
|
|
184
|
+
</head>
|
|
185
|
+
<body>
|
|
186
|
+
<div id="root">${body}</div>
|
|
187
|
+
</body>
|
|
188
|
+
</html>`;
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
export default {
|
|
192
|
+
fetch: handler,
|
|
193
|
+
};
|
|
194
|
+
```
|
|
195
|
+
|
|
196
|
+
```ts [app/routes.ts]
|
|
197
|
+
import type { RouteRecordRaw } from "vue-router";
|
|
198
|
+
|
|
199
|
+
export const routes: RouteRecordRaw[] = [
|
|
200
|
+
{
|
|
201
|
+
path: "/",
|
|
202
|
+
name: "app",
|
|
203
|
+
component: () => import("./app.vue"),
|
|
204
|
+
meta: {
|
|
205
|
+
assets: () => import("./app.vue?assets"),
|
|
206
|
+
},
|
|
207
|
+
children: [
|
|
208
|
+
{
|
|
209
|
+
path: "/",
|
|
210
|
+
name: "home",
|
|
211
|
+
component: () => import("./pages/index.vue"),
|
|
212
|
+
meta: {
|
|
213
|
+
assets: () => import("./pages/index.vue?assets"),
|
|
214
|
+
},
|
|
215
|
+
},
|
|
216
|
+
{
|
|
217
|
+
path: "/about",
|
|
218
|
+
name: "about",
|
|
219
|
+
component: () => import("./pages/about.vue"),
|
|
220
|
+
meta: {
|
|
221
|
+
assets: () => import("./pages/about.vue?assets"),
|
|
222
|
+
},
|
|
223
|
+
},
|
|
224
|
+
{
|
|
225
|
+
path: "/:catchAll(.*)",
|
|
226
|
+
name: "not-found",
|
|
227
|
+
component: () => import("./pages/not-found.vue"),
|
|
228
|
+
meta: {
|
|
229
|
+
assets: () => import("./pages/not-found.vue?assets"),
|
|
230
|
+
},
|
|
231
|
+
},
|
|
232
|
+
],
|
|
233
|
+
},
|
|
234
|
+
];
|
|
235
|
+
```
|
|
236
|
+
|
|
237
|
+
```ts [app/shims.d.ts]
|
|
238
|
+
declare module "*.vue" {
|
|
239
|
+
import type { DefineComponent } from "vue";
|
|
240
|
+
const component: DefineComponent<{}, {}, any>;
|
|
241
|
+
export default component;
|
|
242
|
+
}
|
|
243
|
+
```
|
|
244
|
+
|
|
245
|
+
```css [app/styles.css]
|
|
246
|
+
* {
|
|
247
|
+
box-sizing: border-box;
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
body {
|
|
251
|
+
margin: 0;
|
|
252
|
+
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
|
|
253
|
+
background: #f5f5f5;
|
|
254
|
+
color: #333;
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
main {
|
|
258
|
+
max-width: 800px;
|
|
259
|
+
margin: 0 auto;
|
|
260
|
+
padding: 2rem;
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
h1 {
|
|
264
|
+
font-size: 2.5rem;
|
|
265
|
+
margin-bottom: 0.5rem;
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
.card {
|
|
269
|
+
background: white;
|
|
270
|
+
border-radius: 8px;
|
|
271
|
+
padding: 2rem;
|
|
272
|
+
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
|
|
273
|
+
margin: 2rem 0;
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
button {
|
|
277
|
+
background: rgb(83, 91, 242);
|
|
278
|
+
color: white;
|
|
279
|
+
border: none;
|
|
280
|
+
padding: 0.5rem 1rem;
|
|
281
|
+
border-radius: 4px;
|
|
282
|
+
font-size: 1rem;
|
|
283
|
+
cursor: pointer;
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
button:hover {
|
|
287
|
+
background: #535bf2;
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
.subtitle {
|
|
291
|
+
color: #666;
|
|
292
|
+
font-size: 1.1rem;
|
|
293
|
+
margin-bottom: 2rem;
|
|
294
|
+
}
|
|
295
|
+
```
|
|
296
|
+
|
|
297
|
+
```vue [app/pages/about.vue]
|
|
298
|
+
<template>
|
|
299
|
+
<main>
|
|
300
|
+
<h1>About</h1>
|
|
301
|
+
<div class="card">
|
|
302
|
+
<p>This is a simple Vue Router demo app built with Vite Plugin Fullstack.</p>
|
|
303
|
+
<p>It demonstrates basic routing and server-side rendering.</p>
|
|
304
|
+
</div>
|
|
305
|
+
</main>
|
|
306
|
+
</template>
|
|
307
|
+
```
|
|
308
|
+
|
|
309
|
+
```vue [app/pages/index.vue]
|
|
310
|
+
<script setup lang="ts">
|
|
311
|
+
import { ref } from "vue";
|
|
312
|
+
|
|
313
|
+
const count = ref(0);
|
|
314
|
+
|
|
315
|
+
function increment() {
|
|
316
|
+
count.value++;
|
|
317
|
+
}
|
|
318
|
+
</script>
|
|
319
|
+
|
|
320
|
+
<template>
|
|
321
|
+
<main>
|
|
322
|
+
<div class="hero">
|
|
323
|
+
<h1>Vue Router Custom Framework</h1>
|
|
324
|
+
<p class="subtitle">A simple demo app with Vite</p>
|
|
325
|
+
</div>
|
|
326
|
+
|
|
327
|
+
<div class="card counter-card">
|
|
328
|
+
<p>Count: {{ count }}</p>
|
|
329
|
+
<button @click="increment">Increment</button>
|
|
330
|
+
</div>
|
|
331
|
+
</main>
|
|
332
|
+
</template>
|
|
333
|
+
|
|
334
|
+
<style scoped>
|
|
335
|
+
.hero {
|
|
336
|
+
text-align: center;
|
|
337
|
+
margin-bottom: 2rem;
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
.hero h1 {
|
|
341
|
+
color: rgb(100, 108, 255);
|
|
342
|
+
}
|
|
343
|
+
|
|
344
|
+
.counter-card {
|
|
345
|
+
text-align: center;
|
|
346
|
+
}
|
|
347
|
+
|
|
348
|
+
.counter-card h2 {
|
|
349
|
+
color: #646cff;
|
|
350
|
+
margin-bottom: 1rem;
|
|
351
|
+
}
|
|
352
|
+
|
|
353
|
+
.counter-card p {
|
|
354
|
+
font-size: 1.5rem;
|
|
355
|
+
font-weight: bold;
|
|
356
|
+
margin: 1rem 0;
|
|
357
|
+
}
|
|
358
|
+
</style>
|
|
359
|
+
```
|
|
360
|
+
|
|
361
|
+
```vue [app/pages/not-found.vue]
|
|
362
|
+
<template>
|
|
363
|
+
<main>
|
|
364
|
+
<h1>Not Found 404</h1>
|
|
365
|
+
</main>
|
|
366
|
+
</template>
|
|
367
|
+
```
|
|
368
|
+
</code-tree>
|
|
369
|
+
|
|
370
|
+
Set up server-side rendering (SSR) with Vue, Vue Router, Vite, and Nitro. This setup enables per-route code splitting, head management with unhead, and client hydration.
|
|
371
|
+
|
|
372
|
+
## Overview
|
|
373
|
+
|
|
374
|
+
1. Add the Nitro Vite plugin to your Vite config
|
|
375
|
+
2. Define routes with lazy-loaded components
|
|
376
|
+
3. Create a server entry that renders your app with router support
|
|
377
|
+
4. Create a client entry that hydrates and takes over routing
|
|
378
|
+
5. Create page components
|
|
379
|
+
|
|
380
|
+
## 1. Configure Vite
|
|
381
|
+
Add the Nitro and Vue plugins to your Vite config. Define both `client` and `ssr` environments:
|
|
382
|
+
|
|
383
|
+
```js [vite.config.mjs]
|
|
384
|
+
import vue from "@vitejs/plugin-vue";
|
|
385
|
+
import { defineConfig } from "vite";
|
|
386
|
+
import devtoolsJson from "vite-plugin-devtools-json";
|
|
387
|
+
import { nitro } from "nitro/vite";
|
|
388
|
+
|
|
389
|
+
export default defineConfig((_env) => ({
|
|
390
|
+
plugins: [patchVueExclude(vue(), /\?assets/), devtoolsJson(), nitro()],
|
|
391
|
+
environments: {
|
|
392
|
+
client: { build: { rollupOptions: { input: "./app/entry-client.ts" } } },
|
|
393
|
+
ssr: { build: { rollupOptions: { input: "./app/entry-server.ts" } } },
|
|
394
|
+
},
|
|
395
|
+
}));
|
|
396
|
+
|
|
397
|
+
// Workaround https://github.com/vitejs/vite-plugin-vue/issues/677
|
|
398
|
+
function patchVueExclude(plugin, exclude) {
|
|
399
|
+
const original = plugin.transform.handler;
|
|
400
|
+
plugin.transform.handler = function (...args) {
|
|
401
|
+
if (exclude.test(args[1])) return;
|
|
402
|
+
return original.call(this, ...args);
|
|
403
|
+
};
|
|
404
|
+
return plugin;
|
|
405
|
+
}
|
|
406
|
+
```
|
|
407
|
+
|
|
408
|
+
The `patchVueExclude` helper prevents the Vue plugin from processing asset imports (files with `?assets` query parameter).
|
|
409
|
+
|
|
410
|
+
## 2. Define Routes
|
|
411
|
+
|
|
412
|
+
Create route definitions with lazy-loaded components and asset metadata:
|
|
413
|
+
|
|
414
|
+
```ts [app/routes.ts]
|
|
415
|
+
import type { RouteRecordRaw } from "vue-router";
|
|
416
|
+
|
|
417
|
+
export const routes: RouteRecordRaw[] = [
|
|
418
|
+
{
|
|
419
|
+
path: "/",
|
|
420
|
+
name: "app",
|
|
421
|
+
component: () => import("./app.vue"),
|
|
422
|
+
meta: {
|
|
423
|
+
assets: () => import("./app.vue?assets"),
|
|
424
|
+
},
|
|
425
|
+
children: [
|
|
426
|
+
{
|
|
427
|
+
path: "/",
|
|
428
|
+
name: "home",
|
|
429
|
+
component: () => import("./pages/index.vue"),
|
|
430
|
+
meta: {
|
|
431
|
+
assets: () => import("./pages/index.vue?assets"),
|
|
432
|
+
},
|
|
433
|
+
},
|
|
434
|
+
{
|
|
435
|
+
path: "/about",
|
|
436
|
+
name: "about",
|
|
437
|
+
component: () => import("./pages/about.vue"),
|
|
438
|
+
meta: {
|
|
439
|
+
assets: () => import("./pages/about.vue?assets"),
|
|
440
|
+
},
|
|
441
|
+
},
|
|
442
|
+
{
|
|
443
|
+
path: "/:catchAll(.*)",
|
|
444
|
+
name: "not-found",
|
|
445
|
+
component: () => import("./pages/not-found.vue"),
|
|
446
|
+
meta: {
|
|
447
|
+
assets: () => import("./pages/not-found.vue?assets"),
|
|
448
|
+
},
|
|
449
|
+
},
|
|
450
|
+
],
|
|
451
|
+
},
|
|
452
|
+
];
|
|
453
|
+
```
|
|
454
|
+
|
|
455
|
+
Use dynamic imports for lazy-loaded components to enable code splitting. The `meta.assets` function loads route-specific CSS and JS chunks. Define child routes under a root layout component for nested routing.
|
|
456
|
+
|
|
457
|
+
## 3. Create the Server Entry
|
|
458
|
+
|
|
459
|
+
The server entry renders your Vue app with router support and head management:
|
|
460
|
+
|
|
461
|
+
```ts [app/entry-server.ts]
|
|
462
|
+
import { createSSRApp } from "vue";
|
|
463
|
+
import { renderToString } from "vue/server-renderer";
|
|
464
|
+
import { RouterView, createMemoryHistory, createRouter } from "vue-router";
|
|
465
|
+
import { createHead, transformHtmlTemplate } from "unhead/server";
|
|
466
|
+
|
|
467
|
+
import { routes } from "./routes.ts";
|
|
468
|
+
|
|
469
|
+
import clientAssets from "./entry-client.ts?assets=client";
|
|
470
|
+
|
|
471
|
+
async function handler(request: Request): Promise<Response> {
|
|
472
|
+
const app = createSSRApp(RouterView);
|
|
473
|
+
const router = createRouter({ history: createMemoryHistory(), routes });
|
|
474
|
+
app.use(router);
|
|
475
|
+
|
|
476
|
+
const url = new URL(request.url);
|
|
477
|
+
const href = url.href.slice(url.origin.length);
|
|
478
|
+
|
|
479
|
+
await router.push(href);
|
|
480
|
+
await router.isReady();
|
|
481
|
+
|
|
482
|
+
const assets = clientAssets.merge(
|
|
483
|
+
...(await Promise.all(
|
|
484
|
+
router.currentRoute.value.matched
|
|
485
|
+
.map((to) => to.meta.assets)
|
|
486
|
+
.filter(Boolean)
|
|
487
|
+
.map((fn) => (fn as any)().then((m: any) => m.default))
|
|
488
|
+
))
|
|
489
|
+
);
|
|
490
|
+
|
|
491
|
+
const head = createHead();
|
|
492
|
+
|
|
493
|
+
head.push({
|
|
494
|
+
link: [
|
|
495
|
+
...assets.css.map((attrs: any) => ({ rel: "stylesheet", ...attrs })),
|
|
496
|
+
...assets.js.map((attrs: any) => ({ rel: "modulepreload", ...attrs })),
|
|
497
|
+
],
|
|
498
|
+
script: [{ type: "module", src: clientAssets.entry }],
|
|
499
|
+
});
|
|
500
|
+
|
|
501
|
+
const renderedApp = await renderToString(app);
|
|
502
|
+
|
|
503
|
+
const html = await transformHtmlTemplate(head, htmlTemplate(renderedApp));
|
|
504
|
+
|
|
505
|
+
return new Response(html, {
|
|
506
|
+
headers: { "Content-Type": "text/html;charset=utf-8" },
|
|
507
|
+
});
|
|
508
|
+
}
|
|
509
|
+
|
|
510
|
+
function htmlTemplate(body: string): string {
|
|
511
|
+
return /* html */ `<!DOCTYPE html>
|
|
512
|
+
<html lang="en">
|
|
513
|
+
<head>
|
|
514
|
+
<meta charset="UTF-8" />
|
|
515
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
516
|
+
<title>Vue Router Custom Framework</title>
|
|
517
|
+
</head>
|
|
518
|
+
<body>
|
|
519
|
+
<div id="root">${body}</div>
|
|
520
|
+
</body>
|
|
521
|
+
</html>`;
|
|
522
|
+
}
|
|
523
|
+
|
|
524
|
+
export default {
|
|
525
|
+
fetch: handler,
|
|
526
|
+
};
|
|
527
|
+
```
|
|
528
|
+
|
|
529
|
+
The server uses `createMemoryHistory()` since there's no browser URL bar—the router navigates to the requested URL before rendering. Assets are loaded dynamically based on matched routes, ensuring only the CSS and JS needed for the current page are included. The `unhead` library manages `<head>` elements, injecting stylesheets and scripts via `transformHtmlTemplate`.
|
|
530
|
+
|
|
531
|
+
## 4. Create the Client Entry
|
|
532
|
+
|
|
533
|
+
The client entry hydrates the server-rendered HTML and takes over routing:
|
|
534
|
+
|
|
535
|
+
```ts [app/entry-client.ts]
|
|
536
|
+
import { createSSRApp } from "vue";
|
|
537
|
+
import { RouterView, createRouter, createWebHistory } from "vue-router";
|
|
538
|
+
import { routes } from "./routes.ts";
|
|
539
|
+
|
|
540
|
+
async function main() {
|
|
541
|
+
const app = createSSRApp(RouterView);
|
|
542
|
+
const router = createRouter({ history: createWebHistory(), routes });
|
|
543
|
+
app.use(router);
|
|
544
|
+
|
|
545
|
+
await router.isReady();
|
|
546
|
+
app.mount("#root");
|
|
547
|
+
}
|
|
548
|
+
|
|
549
|
+
// eslint-disable-next-line unicorn/prefer-top-level-await
|
|
550
|
+
main();
|
|
551
|
+
```
|
|
552
|
+
|
|
553
|
+
The client entry creates a Vue app with `createWebHistory()` for browser-based routing. After the router is ready, it mounts to the `#root` element and hydrates the server-rendered HTML.
|
|
554
|
+
|
|
555
|
+
## 5. Create the Root Component
|
|
556
|
+
|
|
557
|
+
The root component provides navigation and renders child routes:
|
|
558
|
+
|
|
559
|
+
```vue [app/app.vue]
|
|
560
|
+
<script setup lang="ts">
|
|
561
|
+
import { RouterLink, RouterView } from "vue-router";
|
|
562
|
+
import "./styles.css";
|
|
563
|
+
</script>
|
|
564
|
+
|
|
565
|
+
<template>
|
|
566
|
+
<nav>
|
|
567
|
+
<ul>
|
|
568
|
+
<li>
|
|
569
|
+
<RouterLink to="/" exact-active-class="active">Home</RouterLink>
|
|
570
|
+
</li>
|
|
571
|
+
<li>
|
|
572
|
+
<RouterLink to="/about" active-class="active">About</RouterLink>
|
|
573
|
+
</li>
|
|
574
|
+
</ul>
|
|
575
|
+
</nav>
|
|
576
|
+
<RouterView />
|
|
577
|
+
</template>
|
|
578
|
+
|
|
579
|
+
<style scoped>
|
|
580
|
+
nav {
|
|
581
|
+
background: white;
|
|
582
|
+
box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
|
|
583
|
+
padding: 1rem;
|
|
584
|
+
}
|
|
585
|
+
|
|
586
|
+
nav ul {
|
|
587
|
+
list-style: none;
|
|
588
|
+
margin: 0;
|
|
589
|
+
padding: 0;
|
|
590
|
+
display: flex;
|
|
591
|
+
gap: 2rem;
|
|
592
|
+
max-width: 800px;
|
|
593
|
+
margin: 0 auto;
|
|
594
|
+
}
|
|
595
|
+
|
|
596
|
+
nav a {
|
|
597
|
+
color: #666;
|
|
598
|
+
text-decoration: none;
|
|
599
|
+
}
|
|
600
|
+
|
|
601
|
+
nav a:hover {
|
|
602
|
+
color: #333;
|
|
603
|
+
}
|
|
604
|
+
|
|
605
|
+
nav a.active {
|
|
606
|
+
color: #646cff;
|
|
607
|
+
}
|
|
608
|
+
</style>
|
|
609
|
+
```
|
|
610
|
+
|
|
611
|
+
## Learn More
|
|
612
|
+
|
|
613
|
+
- [Vue Router Documentation](https://router.vuejs.org/)
|
|
614
|
+
- [Unhead Documentation](https://unhead.unjs.io/)
|
|
615
|
+
- [Renderer](/docs/renderer)
|
|
616
|
+
- [Server Entry](/docs/server-entry)
|