@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,256 @@
|
|
|
1
|
+
# SSR with SolidJS
|
|
2
|
+
|
|
3
|
+
> Server-side rendering with SolidJS 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
|
+
},
|
|
14
|
+
"devDependencies": {
|
|
15
|
+
"nitro": "latest",
|
|
16
|
+
"solid-js": "^1.9.11",
|
|
17
|
+
"vite": "beta",
|
|
18
|
+
"vite-plugin-solid": "^2.11.10"
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
```json [tsconfig.json]
|
|
24
|
+
{
|
|
25
|
+
"extends": "nitro/tsconfig",
|
|
26
|
+
"compilerOptions": {
|
|
27
|
+
"jsx": "preserve",
|
|
28
|
+
"jsxImportSource": "solid-js"
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
```js [vite.config.mjs]
|
|
34
|
+
import solid from "vite-plugin-solid";
|
|
35
|
+
import { defineConfig } from "vite";
|
|
36
|
+
import { nitro } from "nitro/vite";
|
|
37
|
+
|
|
38
|
+
export default defineConfig({
|
|
39
|
+
plugins: [solid({ ssr: true }), nitro()],
|
|
40
|
+
esbuild: { jsx: "preserve", jsxImportSource: "solid-js" },
|
|
41
|
+
environments: {
|
|
42
|
+
ssr: {
|
|
43
|
+
build: { rollupOptions: { input: "./src/entry-server.tsx" } },
|
|
44
|
+
},
|
|
45
|
+
client: {
|
|
46
|
+
build: { rollupOptions: { input: "./src/entry-client.tsx" } },
|
|
47
|
+
},
|
|
48
|
+
},
|
|
49
|
+
});
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
```tsx [src/app.tsx]
|
|
53
|
+
import { createSignal } from "solid-js";
|
|
54
|
+
|
|
55
|
+
export function App() {
|
|
56
|
+
const [count, setCount] = createSignal(0);
|
|
57
|
+
|
|
58
|
+
return (
|
|
59
|
+
<div>
|
|
60
|
+
<h1>Hello, Solid!</h1>
|
|
61
|
+
<button onClick={() => setCount((count) => count + 1)}>Count: {count()}</button>
|
|
62
|
+
</div>
|
|
63
|
+
);
|
|
64
|
+
}
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
```tsx [src/entry-client.tsx]
|
|
68
|
+
import { hydrate } from "solid-js/web";
|
|
69
|
+
import "./styles.css";
|
|
70
|
+
import { App } from "./app.jsx";
|
|
71
|
+
|
|
72
|
+
hydrate(() => <App />, document.querySelector("#app")!);
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
```tsx [src/entry-server.tsx]
|
|
76
|
+
import { renderToStringAsync, HydrationScript } from "solid-js/web";
|
|
77
|
+
import { App } from "./app.jsx";
|
|
78
|
+
|
|
79
|
+
import clientAssets from "./entry-client?assets=client";
|
|
80
|
+
import serverAssets from "./entry-server?assets=ssr";
|
|
81
|
+
|
|
82
|
+
export default {
|
|
83
|
+
async fetch(req: Request): Promise<Response> {
|
|
84
|
+
const appHTML = await renderToStringAsync(() => <App />);
|
|
85
|
+
const rootHTML = await renderToStringAsync(() => <Root appHTML={appHTML} />);
|
|
86
|
+
return new Response(rootHTML, {
|
|
87
|
+
headers: { "Content-Type": "text/html" },
|
|
88
|
+
});
|
|
89
|
+
},
|
|
90
|
+
};
|
|
91
|
+
|
|
92
|
+
function Root(props: { appHTML?: string }) {
|
|
93
|
+
const assets = clientAssets.merge(serverAssets);
|
|
94
|
+
return (
|
|
95
|
+
<html lang="en">
|
|
96
|
+
<head>
|
|
97
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
98
|
+
{assets.css.map((attr: any) => (
|
|
99
|
+
<link key={attr.href} rel="stylesheet" {...attr} />
|
|
100
|
+
))}
|
|
101
|
+
{assets.js.map((attr: any) => (
|
|
102
|
+
<link key={attr.href} type="modulepreload" {...attr} />
|
|
103
|
+
))}
|
|
104
|
+
</head>
|
|
105
|
+
<body>
|
|
106
|
+
<div id="app" innerHTML={props.appHTML || ""} />
|
|
107
|
+
<HydrationScript />
|
|
108
|
+
<script type="module" src={assets.entry} />
|
|
109
|
+
</body>
|
|
110
|
+
</html>
|
|
111
|
+
);
|
|
112
|
+
}
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
```css [src/styles.css]
|
|
116
|
+
div {
|
|
117
|
+
font-family: system-ui, Arial, sans-serif;
|
|
118
|
+
font-size: 20px;
|
|
119
|
+
margin-bottom: 10px;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
button {
|
|
123
|
+
background-color: rgb(147 197 253);
|
|
124
|
+
color: rgb(15 23 42);
|
|
125
|
+
border: none;
|
|
126
|
+
padding: 10px 20px;
|
|
127
|
+
font-size: 16px;
|
|
128
|
+
cursor: pointer;
|
|
129
|
+
border-radius: 5px;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
button:hover {
|
|
133
|
+
background-color: rgb(191 219 254);
|
|
134
|
+
}
|
|
135
|
+
```
|
|
136
|
+
</code-tree>
|
|
137
|
+
|
|
138
|
+
Set up server-side rendering (SSR) with SolidJS, Vite, and Nitro. This setup uses `renderToStringAsync` for HTML generation and supports client hydration.
|
|
139
|
+
|
|
140
|
+
## Overview
|
|
141
|
+
|
|
142
|
+
1. Add the Nitro Vite plugin to your Vite config
|
|
143
|
+
2. Configure client and server entry points
|
|
144
|
+
3. Create a server entry that renders your app to HTML
|
|
145
|
+
4. Create a client entry that hydrates the server-rendered HTML
|
|
146
|
+
|
|
147
|
+
## 1. Configure Vite
|
|
148
|
+
Add the Nitro and SolidJS plugins to your Vite config. SolidJS requires explicit JSX configuration and both `ssr` and `client` environments:
|
|
149
|
+
|
|
150
|
+
```js [vite.config.mjs]
|
|
151
|
+
import solid from "vite-plugin-solid";
|
|
152
|
+
import { defineConfig } from "vite";
|
|
153
|
+
import { nitro } from "nitro/vite";
|
|
154
|
+
|
|
155
|
+
export default defineConfig({
|
|
156
|
+
plugins: [solid({ ssr: true }), nitro()],
|
|
157
|
+
esbuild: { jsx: "preserve", jsxImportSource: "solid-js" },
|
|
158
|
+
environments: {
|
|
159
|
+
ssr: {
|
|
160
|
+
build: { rollupOptions: { input: "./src/entry-server.tsx" } },
|
|
161
|
+
},
|
|
162
|
+
client: {
|
|
163
|
+
build: { rollupOptions: { input: "./src/entry-client.tsx" } },
|
|
164
|
+
},
|
|
165
|
+
},
|
|
166
|
+
});
|
|
167
|
+
```
|
|
168
|
+
|
|
169
|
+
Enable SSR mode in the Solid plugin with `solid({ ssr: true })`. Configure esbuild to preserve JSX for Solid's compiler and use Solid's JSX runtime. SolidJS requires explicit `ssr` and `client` environment configuration in Vite.
|
|
170
|
+
|
|
171
|
+
## 2. Create the App Component
|
|
172
|
+
|
|
173
|
+
Create a shared SolidJS component using reactive signals:
|
|
174
|
+
|
|
175
|
+
```tsx [src/app.tsx]
|
|
176
|
+
import { createSignal } from "solid-js";
|
|
177
|
+
|
|
178
|
+
export function App() {
|
|
179
|
+
const [count, setCount] = createSignal(0);
|
|
180
|
+
|
|
181
|
+
return (
|
|
182
|
+
<div>
|
|
183
|
+
<h1>Hello, Solid!</h1>
|
|
184
|
+
<button onClick={() => setCount((count) => count + 1)}>Count: {count()}</button>
|
|
185
|
+
</div>
|
|
186
|
+
);
|
|
187
|
+
}
|
|
188
|
+
```
|
|
189
|
+
|
|
190
|
+
SolidJS uses signals (`createSignal`) for state management. Unlike React's `useState`, signals are getter functions that you call to read the value.
|
|
191
|
+
|
|
192
|
+
## 3. Create the Server Entry
|
|
193
|
+
|
|
194
|
+
The server entry renders your SolidJS app to HTML using `renderToStringAsync` and includes the `HydrationScript` for client-side hydration:
|
|
195
|
+
|
|
196
|
+
```tsx [src/entry-server.tsx]
|
|
197
|
+
import { renderToStringAsync, HydrationScript } from "solid-js/web";
|
|
198
|
+
import { App } from "./app.jsx";
|
|
199
|
+
|
|
200
|
+
import clientAssets from "./entry-client?assets=client";
|
|
201
|
+
import serverAssets from "./entry-server?assets=ssr";
|
|
202
|
+
|
|
203
|
+
export default {
|
|
204
|
+
async fetch(req: Request): Promise<Response> {
|
|
205
|
+
const appHTML = await renderToStringAsync(() => <App />);
|
|
206
|
+
const rootHTML = await renderToStringAsync(() => <Root appHTML={appHTML} />);
|
|
207
|
+
return new Response(rootHTML, {
|
|
208
|
+
headers: { "Content-Type": "text/html" },
|
|
209
|
+
});
|
|
210
|
+
},
|
|
211
|
+
};
|
|
212
|
+
|
|
213
|
+
function Root(props: { appHTML?: string }) {
|
|
214
|
+
const assets = clientAssets.merge(serverAssets);
|
|
215
|
+
return (
|
|
216
|
+
<html lang="en">
|
|
217
|
+
<head>
|
|
218
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
219
|
+
{assets.css.map((attr: any) => (
|
|
220
|
+
<link key={attr.href} rel="stylesheet" {...attr} />
|
|
221
|
+
))}
|
|
222
|
+
{assets.js.map((attr: any) => (
|
|
223
|
+
<link key={attr.href} type="modulepreload" {...attr} />
|
|
224
|
+
))}
|
|
225
|
+
</head>
|
|
226
|
+
<body>
|
|
227
|
+
<div id="app" innerHTML={props.appHTML || ""} />
|
|
228
|
+
<HydrationScript />
|
|
229
|
+
<script type="module" src={assets.entry} />
|
|
230
|
+
</body>
|
|
231
|
+
</html>
|
|
232
|
+
);
|
|
233
|
+
}
|
|
234
|
+
```
|
|
235
|
+
|
|
236
|
+
SolidJS requires rendering the app separately from the shell (two-phase rendering). The app HTML is injected via `innerHTML` to preserve hydration markers. Include the `HydrationScript` component to inject the script Solid needs to rehydrate on the client. Import assets using the `?assets=client` and `?assets=ssr` query parameters to collect CSS and JS from each entry point.
|
|
237
|
+
|
|
238
|
+
## 4. Create the Client Entry
|
|
239
|
+
|
|
240
|
+
The client entry hydrates the server-rendered HTML, restoring Solid's reactivity:
|
|
241
|
+
|
|
242
|
+
```tsx [src/entry-client.tsx]
|
|
243
|
+
import { hydrate } from "solid-js/web";
|
|
244
|
+
import "./styles.css";
|
|
245
|
+
import { App } from "./app.jsx";
|
|
246
|
+
|
|
247
|
+
hydrate(() => <App />, document.querySelector("#app")!);
|
|
248
|
+
```
|
|
249
|
+
|
|
250
|
+
The `hydrate` function attaches Solid's reactive system to the existing server-rendered DOM inside `#app`. The component is wrapped in a function `() => <App />` as required by Solid's API.
|
|
251
|
+
|
|
252
|
+
## Learn More
|
|
253
|
+
|
|
254
|
+
- [SolidJS Documentation](https://docs.solidjs.com/)
|
|
255
|
+
- [Renderer](/docs/renderer)
|
|
256
|
+
- [Server Entry](/docs/server-entry)
|
|
@@ -0,0 +1,442 @@
|
|
|
1
|
+
# SSR with TanStack Router
|
|
2
|
+
|
|
3
|
+
> Client-side routing with TanStack Router in Nitro using Vite.
|
|
4
|
+
|
|
5
|
+
<code-tree>
|
|
6
|
+
|
|
7
|
+
```html [index.html]
|
|
8
|
+
<!doctype html>
|
|
9
|
+
<html lang="en">
|
|
10
|
+
<head>
|
|
11
|
+
<meta charset="UTF-8" />
|
|
12
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
13
|
+
<title>Nitro + TanStack Router + React</title>
|
|
14
|
+
</head>
|
|
15
|
+
|
|
16
|
+
<body>
|
|
17
|
+
<div id="root"></div>
|
|
18
|
+
<script type="module" src="/src/main.tsx"></script>
|
|
19
|
+
</body>
|
|
20
|
+
</html>
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
```json [package.json]
|
|
24
|
+
{
|
|
25
|
+
"type": "module",
|
|
26
|
+
"scripts": {
|
|
27
|
+
"build": "vite build",
|
|
28
|
+
"dev": "vite dev",
|
|
29
|
+
"preview": "vite preview"
|
|
30
|
+
},
|
|
31
|
+
"devDependencies": {
|
|
32
|
+
"@tanstack/react-router": "^1.158.1",
|
|
33
|
+
"@tanstack/react-router-devtools": "^1.158.1",
|
|
34
|
+
"@tanstack/router-plugin": "^1.158.1",
|
|
35
|
+
"@types/react": "^19.2.13",
|
|
36
|
+
"@types/react-dom": "^19.2.3",
|
|
37
|
+
"@vitejs/plugin-react": "^5.1.3",
|
|
38
|
+
"nitro": "latest",
|
|
39
|
+
"react": "^19.2.4",
|
|
40
|
+
"react-dom": "^19.2.4",
|
|
41
|
+
"vite": "beta"
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
```json [tsconfig.json]
|
|
47
|
+
{
|
|
48
|
+
"extends": "nitro/tsconfig",
|
|
49
|
+
"compilerOptions": {
|
|
50
|
+
"baseUrl": ".",
|
|
51
|
+
"jsx": "react-jsx",
|
|
52
|
+
"paths": {
|
|
53
|
+
"@/*": ["sec/*"]
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
```js [vite.config.mjs]
|
|
60
|
+
import { defineConfig } from "vite";
|
|
61
|
+
import { nitro } from "nitro/vite";
|
|
62
|
+
import react from "@vitejs/plugin-react";
|
|
63
|
+
import { tanstackRouter } from "@tanstack/router-plugin/vite";
|
|
64
|
+
|
|
65
|
+
export default defineConfig({
|
|
66
|
+
plugins: [tanstackRouter({ target: "react", autoCodeSplitting: true }), react(), nitro()],
|
|
67
|
+
});
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
```tsx [src/main.tsx]
|
|
71
|
+
import { StrictMode } from "react";
|
|
72
|
+
import ReactDOM from "react-dom/client";
|
|
73
|
+
import { RouterProvider, createRouter } from "@tanstack/react-router";
|
|
74
|
+
|
|
75
|
+
// Import the generated route tree
|
|
76
|
+
import { routeTree } from "./routeTree.gen.ts";
|
|
77
|
+
|
|
78
|
+
// Create a new router instance
|
|
79
|
+
const router = createRouter({ routeTree });
|
|
80
|
+
|
|
81
|
+
// Register the router instance for type safety
|
|
82
|
+
declare module "@tanstack/react-router" {
|
|
83
|
+
interface Register {
|
|
84
|
+
router: typeof router;
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
// Render the app
|
|
89
|
+
const rootElement = document.querySelector("#root")!;
|
|
90
|
+
if (!rootElement.innerHTML) {
|
|
91
|
+
const root = ReactDOM.createRoot(rootElement);
|
|
92
|
+
root.render(
|
|
93
|
+
<StrictMode>
|
|
94
|
+
<RouterProvider router={router} />
|
|
95
|
+
</StrictMode>
|
|
96
|
+
);
|
|
97
|
+
}
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
```ts [src/routeTree.gen.ts]
|
|
101
|
+
/* eslint-disable */
|
|
102
|
+
|
|
103
|
+
// @ts-nocheck
|
|
104
|
+
|
|
105
|
+
// noinspection JSUnusedGlobalSymbols
|
|
106
|
+
|
|
107
|
+
// This file was automatically generated by TanStack Router.
|
|
108
|
+
// You should NOT make any changes in this file as it will be overwritten.
|
|
109
|
+
// Additionally, you should also exclude this file from your linter and/or formatter to prevent it from being checked or modified.
|
|
110
|
+
|
|
111
|
+
import { Route as rootRouteImport } from './routes/__root'
|
|
112
|
+
import { Route as IndexRouteImport } from './routes/index'
|
|
113
|
+
|
|
114
|
+
const IndexRoute = IndexRouteImport.update({
|
|
115
|
+
id: '/',
|
|
116
|
+
path: '/',
|
|
117
|
+
getParentRoute: () => rootRouteImport,
|
|
118
|
+
} as any)
|
|
119
|
+
|
|
120
|
+
export interface FileRoutesByFullPath {
|
|
121
|
+
'/': typeof IndexRoute
|
|
122
|
+
}
|
|
123
|
+
export interface FileRoutesByTo {
|
|
124
|
+
'/': typeof IndexRoute
|
|
125
|
+
}
|
|
126
|
+
export interface FileRoutesById {
|
|
127
|
+
__root__: typeof rootRouteImport
|
|
128
|
+
'/': typeof IndexRoute
|
|
129
|
+
}
|
|
130
|
+
export interface FileRouteTypes {
|
|
131
|
+
fileRoutesByFullPath: FileRoutesByFullPath
|
|
132
|
+
fullPaths: '/'
|
|
133
|
+
fileRoutesByTo: FileRoutesByTo
|
|
134
|
+
to: '/'
|
|
135
|
+
id: '__root__' | '/'
|
|
136
|
+
fileRoutesById: FileRoutesById
|
|
137
|
+
}
|
|
138
|
+
export interface RootRouteChildren {
|
|
139
|
+
IndexRoute: typeof IndexRoute
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
declare module '@tanstack/react-router' {
|
|
143
|
+
interface FileRoutesByPath {
|
|
144
|
+
'/': {
|
|
145
|
+
id: '/'
|
|
146
|
+
path: '/'
|
|
147
|
+
fullPath: '/'
|
|
148
|
+
preLoaderRoute: typeof IndexRouteImport
|
|
149
|
+
parentRoute: typeof rootRouteImport
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
const rootRouteChildren: RootRouteChildren = {
|
|
155
|
+
IndexRoute: IndexRoute,
|
|
156
|
+
}
|
|
157
|
+
export const routeTree = rootRouteImport
|
|
158
|
+
._addFileChildren(rootRouteChildren)
|
|
159
|
+
._addFileTypes<FileRouteTypes>()
|
|
160
|
+
```
|
|
161
|
+
|
|
162
|
+
```css [src/assets/main.css]
|
|
163
|
+
:root {
|
|
164
|
+
font-family: system-ui, Avenir, Helvetica, Arial, sans-serif;
|
|
165
|
+
line-height: 1.5;
|
|
166
|
+
font-weight: 400;
|
|
167
|
+
|
|
168
|
+
color-scheme: light dark;
|
|
169
|
+
color: rgba(255, 255, 255, 0.87);
|
|
170
|
+
background-color: #242424;
|
|
171
|
+
|
|
172
|
+
font-synthesis: none;
|
|
173
|
+
text-rendering: optimizeLegibility;
|
|
174
|
+
-webkit-font-smoothing: antialiased;
|
|
175
|
+
-moz-osx-font-smoothing: grayscale;
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
a {
|
|
179
|
+
font-weight: 500;
|
|
180
|
+
color: #ff2056;
|
|
181
|
+
text-decoration: inherit;
|
|
182
|
+
}
|
|
183
|
+
a:hover {
|
|
184
|
+
color: #ff637e;
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
body {
|
|
188
|
+
margin: 0;
|
|
189
|
+
display: flex;
|
|
190
|
+
flex-direction: column;
|
|
191
|
+
place-items: center;
|
|
192
|
+
justify-content: center;
|
|
193
|
+
min-width: 320px;
|
|
194
|
+
min-height: 100vh;
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
h1 {
|
|
198
|
+
font-size: 3.2em;
|
|
199
|
+
line-height: 1.1;
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
#app {
|
|
203
|
+
max-width: 1280px;
|
|
204
|
+
margin: 0 auto;
|
|
205
|
+
padding: 2rem;
|
|
206
|
+
text-align: center;
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
.logo {
|
|
210
|
+
height: 6em;
|
|
211
|
+
padding: 1.5em;
|
|
212
|
+
will-change: filter;
|
|
213
|
+
transition: filter 300ms;
|
|
214
|
+
transition: transform 300ms;
|
|
215
|
+
}
|
|
216
|
+
.logo:hover {
|
|
217
|
+
transform: scale(1.1);
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
.card {
|
|
221
|
+
padding: 2em;
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
.read-the-docs {
|
|
225
|
+
color: #888;
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
button {
|
|
229
|
+
border-radius: 8px;
|
|
230
|
+
border: 1px solid transparent;
|
|
231
|
+
padding: 0.6em 1.2em;
|
|
232
|
+
font-size: 1em;
|
|
233
|
+
font-weight: 500;
|
|
234
|
+
font-family: inherit;
|
|
235
|
+
background-color: #1a1a1a;
|
|
236
|
+
cursor: pointer;
|
|
237
|
+
transition: border-color 0.25s;
|
|
238
|
+
}
|
|
239
|
+
button:hover {
|
|
240
|
+
border-color: #646cff;
|
|
241
|
+
}
|
|
242
|
+
button:focus,
|
|
243
|
+
button:focus-visible {
|
|
244
|
+
outline: 4px auto -webkit-focus-ring-color;
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
@media (prefers-color-scheme: light) {
|
|
248
|
+
:root {
|
|
249
|
+
color: #213547;
|
|
250
|
+
background-color: #ffffff;
|
|
251
|
+
}
|
|
252
|
+
a:hover {
|
|
253
|
+
color: #747bff;
|
|
254
|
+
}
|
|
255
|
+
button {
|
|
256
|
+
background-color: #f9f9f9;
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
```
|
|
260
|
+
|
|
261
|
+
```tsx [src/routes/__root.tsx]
|
|
262
|
+
import { createRootRoute, Link, Outlet } from "@tanstack/react-router";
|
|
263
|
+
import { TanStackRouterDevtools } from "@tanstack/react-router-devtools";
|
|
264
|
+
|
|
265
|
+
const RootLayout = () => (
|
|
266
|
+
<>
|
|
267
|
+
<div className="p-2 flex gap-2">
|
|
268
|
+
<Link to="/" className="[&.active]:font-bold">
|
|
269
|
+
Home
|
|
270
|
+
</Link>
|
|
271
|
+
</div>
|
|
272
|
+
<hr />
|
|
273
|
+
<Outlet />
|
|
274
|
+
<TanStackRouterDevtools />
|
|
275
|
+
</>
|
|
276
|
+
);
|
|
277
|
+
|
|
278
|
+
export const Route = createRootRoute({ component: RootLayout });
|
|
279
|
+
```
|
|
280
|
+
|
|
281
|
+
```tsx [src/routes/index.tsx]
|
|
282
|
+
import { createFileRoute } from "@tanstack/react-router";
|
|
283
|
+
|
|
284
|
+
export const Route = createFileRoute("/")({
|
|
285
|
+
loader: async () => {
|
|
286
|
+
const r = await fetch("/api/hello");
|
|
287
|
+
return r.json();
|
|
288
|
+
},
|
|
289
|
+
component: Index,
|
|
290
|
+
});
|
|
291
|
+
|
|
292
|
+
function Index() {
|
|
293
|
+
const r = Route.useLoaderData();
|
|
294
|
+
|
|
295
|
+
return (
|
|
296
|
+
<div className="p-2">
|
|
297
|
+
<h3>{JSON.stringify(r)}</h3>
|
|
298
|
+
</div>
|
|
299
|
+
);
|
|
300
|
+
}
|
|
301
|
+
```
|
|
302
|
+
</code-tree>
|
|
303
|
+
|
|
304
|
+
Set up TanStack Router with React, Vite, and Nitro. This setup provides file-based routing with type-safe navigation and automatic code splitting.
|
|
305
|
+
|
|
306
|
+
## Overview
|
|
307
|
+
|
|
308
|
+
1. Add the Nitro Vite plugin to your Vite config
|
|
309
|
+
2. Create an HTML template with your app entry
|
|
310
|
+
3. Create a main entry that initializes the router
|
|
311
|
+
4. Define routes using file-based routing
|
|
312
|
+
|
|
313
|
+
## 1. Configure Vite
|
|
314
|
+
Add the Nitro, React, and TanStack Router plugins to your Vite config:
|
|
315
|
+
|
|
316
|
+
```js [vite.config.mjs]
|
|
317
|
+
import { defineConfig } from "vite";
|
|
318
|
+
import { nitro } from "nitro/vite";
|
|
319
|
+
import react from "@vitejs/plugin-react";
|
|
320
|
+
import { tanstackRouter } from "@tanstack/router-plugin/vite";
|
|
321
|
+
|
|
322
|
+
export default defineConfig({
|
|
323
|
+
plugins: [tanstackRouter({ target: "react", autoCodeSplitting: true }), react(), nitro()],
|
|
324
|
+
});
|
|
325
|
+
```
|
|
326
|
+
|
|
327
|
+
The `tanstackRouter` plugin generates a route tree from your `routes/` directory structure. Enable `autoCodeSplitting` to automatically split routes into separate chunks. Place the TanStack Router plugin before the React plugin in the array.
|
|
328
|
+
|
|
329
|
+
## 2. Create the HTML Template
|
|
330
|
+
|
|
331
|
+
Create an HTML file that serves as your app shell:
|
|
332
|
+
|
|
333
|
+
```html [index.html]
|
|
334
|
+
<!doctype html>
|
|
335
|
+
<html lang="en">
|
|
336
|
+
<head>
|
|
337
|
+
<meta charset="UTF-8" />
|
|
338
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
339
|
+
<title>Nitro + TanStack Router + React</title>
|
|
340
|
+
</head>
|
|
341
|
+
|
|
342
|
+
<body>
|
|
343
|
+
<div id="root"></div>
|
|
344
|
+
<script type="module" src="/src/main.tsx"></script>
|
|
345
|
+
</body>
|
|
346
|
+
</html>
|
|
347
|
+
```
|
|
348
|
+
|
|
349
|
+
## 3. Create the App Entry
|
|
350
|
+
|
|
351
|
+
Create the main entry that initializes TanStack Router:
|
|
352
|
+
|
|
353
|
+
```tsx [src/main.tsx]
|
|
354
|
+
import { StrictMode } from "react";
|
|
355
|
+
import ReactDOM from "react-dom/client";
|
|
356
|
+
import { RouterProvider, createRouter } from "@tanstack/react-router";
|
|
357
|
+
|
|
358
|
+
// Import the generated route tree
|
|
359
|
+
import { routeTree } from "./routeTree.gen.ts";
|
|
360
|
+
|
|
361
|
+
// Create a new router instance
|
|
362
|
+
const router = createRouter({ routeTree });
|
|
363
|
+
|
|
364
|
+
// Register the router instance for type safety
|
|
365
|
+
declare module "@tanstack/react-router" {
|
|
366
|
+
interface Register {
|
|
367
|
+
router: typeof router;
|
|
368
|
+
}
|
|
369
|
+
}
|
|
370
|
+
|
|
371
|
+
// Render the app
|
|
372
|
+
const rootElement = document.querySelector("#root")!;
|
|
373
|
+
if (!rootElement.innerHTML) {
|
|
374
|
+
const root = ReactDOM.createRoot(rootElement);
|
|
375
|
+
root.render(
|
|
376
|
+
<StrictMode>
|
|
377
|
+
<RouterProvider router={router} />
|
|
378
|
+
</StrictMode>
|
|
379
|
+
);
|
|
380
|
+
}
|
|
381
|
+
```
|
|
382
|
+
|
|
383
|
+
The `routeTree.gen.ts` file is auto-generated from your `routes/` directory structure. The `Register` interface declaration provides full type inference for route paths and params. The `!rootElement.innerHTML` check prevents re-rendering during hot module replacement.
|
|
384
|
+
|
|
385
|
+
## 4. Create the Root Route
|
|
386
|
+
|
|
387
|
+
The root route (`__root.tsx`) defines your app's layout:
|
|
388
|
+
|
|
389
|
+
```tsx [src/routes/__root.tsx]
|
|
390
|
+
import { createRootRoute, Link, Outlet } from "@tanstack/react-router";
|
|
391
|
+
import { TanStackRouterDevtools } from "@tanstack/react-router-devtools";
|
|
392
|
+
|
|
393
|
+
const RootLayout = () => (
|
|
394
|
+
<>
|
|
395
|
+
<div className="p-2 flex gap-2">
|
|
396
|
+
<Link to="/" className="[&.active]:font-bold">
|
|
397
|
+
Home
|
|
398
|
+
</Link>
|
|
399
|
+
</div>
|
|
400
|
+
<hr />
|
|
401
|
+
<Outlet />
|
|
402
|
+
<TanStackRouterDevtools />
|
|
403
|
+
</>
|
|
404
|
+
);
|
|
405
|
+
|
|
406
|
+
export const Route = createRootRoute({ component: RootLayout });
|
|
407
|
+
```
|
|
408
|
+
|
|
409
|
+
Use `Link` for type-safe navigation with active state styling. The `Outlet` component renders child routes. Include `TanStackRouterDevtools` for development tools (automatically removed in production).
|
|
410
|
+
|
|
411
|
+
## 5. Create Page Routes
|
|
412
|
+
|
|
413
|
+
Page routes use `createFileRoute` and can include loaders:
|
|
414
|
+
|
|
415
|
+
```tsx [src/routes/index.tsx]
|
|
416
|
+
import { createFileRoute } from "@tanstack/react-router";
|
|
417
|
+
|
|
418
|
+
export const Route = createFileRoute("/")({
|
|
419
|
+
loader: async () => {
|
|
420
|
+
const r = await fetch("/api/hello");
|
|
421
|
+
return r.json();
|
|
422
|
+
},
|
|
423
|
+
component: Index,
|
|
424
|
+
});
|
|
425
|
+
|
|
426
|
+
function Index() {
|
|
427
|
+
const r = Route.useLoaderData();
|
|
428
|
+
|
|
429
|
+
return (
|
|
430
|
+
<div className="p-2">
|
|
431
|
+
<h3>{JSON.stringify(r)}</h3>
|
|
432
|
+
</div>
|
|
433
|
+
);
|
|
434
|
+
}
|
|
435
|
+
```
|
|
436
|
+
|
|
437
|
+
Fetch data before rendering with the `loader` function—data is available via `Route.useLoaderData()`. File paths determine URL paths: `routes/index.tsx` maps to `/`, `routes/about.tsx` to `/about`, and `routes/users/$id.tsx` to `/users/:id`.
|
|
438
|
+
|
|
439
|
+
## Learn More
|
|
440
|
+
|
|
441
|
+
- [TanStack Router Documentation](https://tanstack.com/router)
|
|
442
|
+
- [Renderer](/docs/renderer)
|