bởi pip

Nitro extends Vite apps with a production-ready server featuring file-based routing, SSR, WebSockets, caching, and zero-config deployment across Node.js, Deno, Bun, Cloudflare Workers, and more.
Nitro is a production-ready server framework that wraps your application with typed server routes, middleware, and deployment presets targeting any platform (Node, Bun, Deno, Cloudflare Workers, AWS Lambda, and more). It is aimed at library authors and full-stack developers who need a zero-config server layer with first-class TypeScript support and a unified runtime API. The buyer integrates source/ to gain full control over the build pipeline, preset resolution, CLI tooling, and type infrastructure without depending on a black-box package.
cli/ - Citty-based CLI entry point exposing dev, build, deploy, prepare, task, preview, and docs subcommands.config/ - Configuration loading, merging, and per-concern resolvers (paths, storage, database, assets, route rules, etc.).dev/ - Development server implementation including the Vite-backed app server and virtual file system.prerender/ - Static pre-rendering engine and associated utilities.presets/ - Platform deployment presets (Cloudflare, AWS Lambda, Netlify, Bun, Node, etc.) and preset resolution helpers.runtime/ - Server runtime code that ships into the final output bundle.types/ - Complete TypeScript type definitions re-exported from all subsystems.utils/ - Shared internal utilities.builder.ts - Rolldown-based production build orchestration.global.ts - Global augmentation bootstrapping.module.ts - Nitro module API surface.nitro.ts - Core Nitro instance creation (createNitro).preview.ts - Production preview server launcher.routing.ts - Route scanning and handler wiring.scan.ts - File-system scanning for routes, middleware, plugins, and tasks.task.ts - Server task runner API.vite.ts - Vite plugin integration helpers.npm install consola crossws db0 env-runner h3 hookable nf3 ocache ofetch ohash rolldown srvx unenv unstorage
npm install user@example.com
Khởi chạy sandbox cách ly và chạy phía máy chủ — không cần cài đặt cục bộ.
Tetrees AI Review cho phiên bản này
This Express backend / api completed archive review. Structure, dependency manifests, documentation, functional source, and common risk patterns were checked by the Tetrees verification pipeline; runtime phases are stated separately.
Deterministic AVCP artifact review
Quy trình avcp-2026-08-04.1 · SHA-256 cd506e1cfa8d6e53…
This version-scoped review deterministically inspects the submitted archive for structure, dependencies, documentation, functional source, and common malicious or high-risk signals. Build and test phases are reported as passed only after an isolated sandbox audition. It is not a guarantee of perfect security.
Đã đánh giá 4 thg 8, 2026
Đưa sản phẩm này thẳng vào AI IDE, trình tạo web hoặc cloud IDE của bạn.
Kết nối Tetrees với AI IDE tương thích để liệt kê sản phẩm bạn sở hữu và nhận ZIP đã xác minh mà không cấp quyền tải lên của người bán.
Chưa có đánh giá.
Sign in to join the discussion
Loading discussion…
No native build steps or pod installs are required. All packages are pure JavaScript/TypeScript.
source/ directory into your project root, e.g. ./nitro-src/.tsconfig.json, add path aliases so your code can resolve the internal modules:{
"compilerOptions": {
"baseUrl": ".",
"paths": {
"nitro-src/*": ["./nitro-src/*"]
},
"moduleResolution": "Bundler",
"target": "ESNext",
"module": "ESNext"
}
}
"type": "module" is set in your package.json because the source uses ESM throughout.# Optional: override the preset used for builds
NITRO_PRESET=node
# Optional: root directory of the project
NITRO_ROOT=./
package.json script at the CLI entry:{
"scripts": {
"dev": "tsx nitro-src/cli/index.ts dev",
"build": "tsx nitro-src/cli/index.ts build"
}
}
import "nitro-src/types/index.ts";
import { resolvePreset } from "nitro-src/presets/index.ts";
function resolvePreset(name: PresetNameInput, opts?: PresetOptions): Promise<NitroPreset>;
Resolves a named deployment preset (e.g. "cloudflare", "aws-lambda", "node") to its full preset object. Call this when building a custom build pipeline that needs to select the output target dynamically, such as when reading NITRO_PRESET from the environment and applying the matching adapter configuration.
import type { PresetName, PresetNameInput, PresetOptions } from "nitro-src/presets/index.ts";
type PresetNameInput = PresetName | (string & {});
Union of all valid preset name literals plus an open string for custom presets. Use PresetNameInput for function parameters that accept a preset identifier, and PresetName when you want strict validation of known platform targets.
import { defineCommand } from "citty";
// Nitro's CLI is composed of citty commands wired in cli/index.ts
// Each subcommand is a lazy-loaded citty command definition.
const cmd = defineCommand({
meta: { name: "my-cmd", description: "..." },
async run(ctx) { /* ... */ },
});
The CLI tree in cli/index.ts uses defineCommand from citty. When extending or embedding the Nitro CLI into your own tooling, import defineCommand and compose commands the same way Nitro does, then pass them as subCommands entries.
A custom build script reads the target platform from an environment variable and retrieves the matching Nitro preset configuration before invoking the bundler.
import { resolvePreset } from "./nitro-src/presets/index.ts";
import type { PresetNameInput } from "./nitro-src/presets/index.ts";
async function getBuildPreset(): Promise<void> {
const presetName: PresetNameInput =
(process.env.NITRO_PRESET as PresetNameInput) ?? "node";
const preset = await resolvePreset(presetName);
console.log("Resolved preset:", preset);
// Pass `preset` into your Nitro build configuration
}
getBuildPreset();
Augment the global Nitro type environment in one import so that defineEventHandler, H3Event, and runtime-config types are all available project-wide.
// server/types.ts – import once, augments globals for the whole project
import "nitro-src/types/index.ts";
// server/routes/hello.ts
import type { EventHandler } from "h3";
const handler: EventHandler = (event) => {
return { message: "hello from typed Nitro route" };
};
export default handler;
A monorepo root script wires the Nitro CLI subcommands into a larger Citty-based CLI so developers run a single tool binary for all operations.
import { defineCommand, runMain } from "citty";
const main = defineCommand({
meta: { name: "tool", description: "Monorepo toolchain" },
subCommands: {
// Lazy-load Nitro's own subcommands
dev: () =>
import("./nitro-src/cli/commands/dev.ts").then((r) => r.default),
build: () =>
import("./nitro-src/cli/commands/build.ts").then((r) => r.default),
task: () =>
import("./nitro-src/cli/commands/task/index.ts").then((r) => r.default),
// Add custom project commands alongside
lint: () => import("./tools/lint.ts").then((r) => r.default),
},
});
runMain(main);
cli/index.ts - Entry point for the nitro binary; wires all subcommands via citty's defineCommand / runMain.cli/common.ts - Shared CLI utilities (argument parsing helpers, logger setup).cli/commands/build.ts - nitro build command implementation.cli/commands/dev.ts - nitro dev command; starts the development server with HMR.cli/commands/deploy.ts - nitro deploy command for platform deployments.cli/commands/prepare.ts - nitro prepare command; generates type stubs.cli/commands/preview.ts - nitro preview command; serves the built output locally.cli/commands/docs.ts - Opens Nitro documentation in the browser.cli/commands/task/index.ts - Parent task command grouping list and run subcommands.cli/commands/task/list.ts - Lists registered server tasks.cli/commands/task/run.ts - Runs a named server task with optional payload.config/defaults.ts - Default configuration values applied before user config.config/loader.ts - Loads and merges nitro.config.ts / nuxt.config.ts configuration.config/update.ts - Applies incremental config updates at dev-reload time.config/resolvers/ - One resolver per concern (paths, storage, database, assets, route rules, etc.) applied in sequence during config normalization.dev/app.ts - Vite-backed development app server with middleware chain.dev/server.ts - Dev server lifecycle (start, stop, reload).dev/vfs.ts - Virtual file system used during development to serve generated files.prerender/prerender.ts - Crawls routes and writes static HTML output.prerender/utils.ts - URL normalization and route filtering helpers for pre-rendering.presets/_nitro/ - Internal base preset shared by all platform presets.presets/_static/ - Static file serving preset.presets/_utils/ - Shared preset utility functions.presets/index.ts - Public re-export of resolvePreset and preset types.presets/<platform>/ - One directory per deployment target containing preset config and runtime shims.runtime/ - Code bundled into the server output: request handling, storage, caching, task scheduling.types/index.ts - Barrel that re-exports all Nitro type definitions and triggers module augmentation.types/fetch/ - Typed $fetch utilities including match helpers and serialization types.builder.ts - Orchestrates the Rolldown bundle pipeline for production builds.global.ts - Side-effectful global augmentation (adds Nitro globals to the TypeScript environment).module.ts - API for authoring Nitro modules (plugin system for config-time extensions).nitro.ts - createNitro factory and Nitro instance management.preview.ts - Launches a local preview of the production build output.routing.ts - Maps scanned handler files to H3 router entries.scan.ts - Walks server/routes, server/middleware, server/plugins, and server/tasks directories.task.ts - Defines the server-side task runner (schedule / run named async jobs).vite.ts - Exposes Nitro as a Vite plugin for framework integration.import/export with .ts extensions; ensure "type": "module" in package.json and use tsx or a bundler that handles .ts imports.nitro/meta import at CLI startup: cli/index.ts imports nitro/meta for the version string; add "nitro/meta" to your tsconfig paths or install the nitro package alongside the source copy.builder.ts uses rolldown (not Rollup); pin rolldown to the exact version listed in the upstream package.json to avoid API mismatches.types/_types.gen.ts is a generated file; run nitro prepare once to materialize it before TypeScript compilation.db0 dialect imports: The database resolver imports dialect-specific drivers from db0; install only the connectors you actually use to avoid missing optional native modules."moduleResolution": "Bundler" (not "Node16") in tsconfig.json; several internal imports rely on extensionless resolution that Node16 rejects.I have a copy of the Nitro v3 server framework source located at `./nitro-src/`
and a USAGE.md guide at `./USAGE.md`. The upstream package is `user@example.com`.
My project is a Node.js TypeScript application using [describe your stack].
Please help me integrate Nitro step-by-step:
1. Read `USAGE.md` sections "Project setup" and "Public API" first.
2. Wire `./nitro-src/types/index.ts` so TypeScript picks up all Nitro type augmentations.
3. Use `resolvePreset` from `./nitro-src/presets/index.ts` to select the correct
deployment target based on my `NITRO_PRESET` environment variable.
4. Embed the Nitro CLI commands from `./nitro-src/cli/commands/` into my existing
Citty CLI, adding `dev`, `build`, and `task` subcommands.
5. Show me how to define a server route handler that is correctly typed using
the types exported from `./nitro-src/types/`.
6. Point out any `tsconfig.json` or `package.json` changes needed.
7. Flag any pitfalls from the "Common pitfalls and fixes" section that apply.
Work only with symbols and file paths documented in USAGE.md; do not invent APIs.
Nitro is released under the MIT License (see source/LICENSE if present, or the upstream repository). Source and full documentation are available at https://github.com/nitrojs/nitro and https://nitro.build. Upstream package: nitro on npm.
This product’s unique contribution is clean room implementation of valuable code block into AVCP compatible standard.
Hướng dẫn cài đặt đầy đủ và prompt tích hợp sẽ mở khóa sau khi mua.
Automation, Utilities & Developer Tools
Miễn phí