by kestrel

Nitro extends Vite apps with a zero-config, production-ready server supporting file-based routing, SSR, WebSockets, caching, and deployment to any platform.
Nitro is a production-ready server framework built on top of Vite that compiles your server routes and handlers into a deployable artifact runnable on Node.js, Bun, Deno, Cloudflare Workers, AWS Lambda, and many other targets. This block provides the full Nitro v3 source including the CLI, config resolution pipeline, runtime, preset system, and prerender engine. Typical buyers are full-stack TypeScript teams embedding Nitro as the server layer of a Nuxt app or a standalone API service.
cli/ - Entry point and subcommands for the nitro CLI (dev, build, deploy, prepare, preview, docs, task)config/ - Config loading, defaults, and a suite of per-concern resolvers (paths, assets, storage, database, route-rules, unenv, tracing, etc.)dev/ - Development server app, vfs overlay, and live-reload serverprerender/ - Static prerendering engine and URL utility helperspresets/ - Platform-specific output presets (Node, Bun, Deno, Cloudflare, AWS Lambda, Netlify, Vercel, etc.)runtime/ - Server runtime shipped into the output bundletypes/ - Full TypeScript type surface: config, hooks, handlers, fetch, route-rules, build, prerender, runner, moduleutils/ - Shared internal utilitiesbuilder.ts - Orchestrates the Rolldown build pipelineglobal.ts - Global augmentations and re-exportsmodule.ts - Public module integration APInitro.ts - Core createNitro factory and lifecyclepreview.ts - Local preview server helperrouting.ts - Route scanning and handler wiringscan.ts - File-system scanning for server routes and middlewaretask.ts - Server task registration and execution enginevite.ts - Vite plugin integration surfacenpm install consola crossws db0 env-runner h3 hookable nf3 ocache ofetch ohash rolldown srvx unenv unstorage
npm install --save-dev user@example.com citty
No native build steps are required. All packages are pure JS/TS. If you target Bun or Deno runtimes their respective toolchains must be available in the deployment environment, but the build itself runs on Node.js.
Spin up an isolated sandbox and run it server-side — no local setup.
Tetrees AI Review of this version
This TypeScript cli / script 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
Pipeline avcp-2026-08-04.1 · SHA-256 c80a7a2cc2e1a29e…
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.
Reviewed Aug 4, 2026
Push this product straight into your AI IDE, web builder or cloud IDE.
Connect Tetrees to a compatible AI IDE, list products you own, and request the verified ZIP without exposing seller upload controls.
No reviews yet.
Sign in to join the discussion
Loading discussion…
Drop the source. Place the purchased source/ directory at the root of your project, e.g. <project-root>/nitro-src/.
TypeScript config. Add a path alias so your own code can reach Nitro types:
{
"compilerOptions": {
"paths": {
"nitro-src/*": ["./nitro-src/*"]
},
"moduleResolution": "bundler",
"target": "ESNext",
"module": "ESNext"
}
}
Environment variables. Nitro reads from process.env at build time for preset selection and from runtimeConfig at runtime. Set NITRO_PRESET to target a specific platform:
NITRO_PRESET=node-server # or cloudflare, aws-lambda, bun, etc.
Wire Nitro into your project entry. Import createNitro from nitro-src/nitro.ts and build from nitro-src/builder.ts:
import { createNitro } from "./nitro-src/nitro.ts";
import { build } from "./nitro-src/builder.ts";
Use the CLI directly (after the package is installed):
npx nitro dev # dev server
npx nitro build # production build
npx nitro preview
resolvePresetimport { resolvePreset } from "./nitro-src/presets/index.ts";
function resolvePreset(
name: PresetNameInput,
options?: PresetOptions
): Promise<NitroPreset>;
Call this to dynamically load the platform output preset by name. Used internally by createNitro but also useful when you need to inspect or extend a preset programmatically before passing it to the build pipeline.
PresetName / PresetOptionsimport type { PresetName, PresetNameInput, PresetOptions } from "./nitro-src/presets/index.ts";
PresetName is the union of all supported platform identifiers ("node-server", "cloudflare", "aws-lambda", etc.). PresetNameInput is a looser form that also accepts aliases. PresetOptions carries per-preset configuration. Use these types to constrain config objects passed to your own wrapper around createNitro.
types/index.tsimport type {
NitroConfig,
NitroHooks,
NitroPreset,
NitroBuildInfo,
NitroRouteRules,
NitroPrerenderRoute,
NitroModuleInput,
} from "./nitro-src/types/index.ts";
The types/ barrel re-exports every public interface in the framework. Import from here instead of individual sub-files so your code stays forward-compatible as internal paths shift between beta versions.
A CI script that creates a Nitro instance with a specific preset and triggers a full build, then exits.
import { createNitro } from "./nitro-src/nitro.ts";
import { build, copyPublicAssets, prepare } from "./nitro-src/builder.ts";
import type { NitroConfig } from "./nitro-src/types/index.ts";
const config: NitroConfig = {
preset: (process.env.NITRO_PRESET as any) ?? "node-server",
rootDir: process.cwd(),
output: {
dir: ".output",
},
};
async function main() {
const nitro = await createNitro(config);
await prepare(nitro);
await copyPublicAssets(nitro);
await build(nitro);
await nitro.close();
console.log("Build complete");
}
main().catch((err) => {
console.error(err);
process.exit(1);
});
Useful when you need to validate that a target preset exists before kicking off a long CI pipeline.
import { resolvePreset } from "./nitro-src/presets/index.ts";
import type { PresetNameInput } from "./nitro-src/presets/index.ts";
async function inspectPreset(name: PresetNameInput) {
const preset = await resolvePreset(name);
console.log("Resolved preset:", JSON.stringify(preset, null, 2));
}
// Validate that the "aws-lambda" preset is available
inspectPreset("aws-lambda").catch(console.error);
Nitro exposes server tasks as first-class primitives. The snippet below registers a task in your server code and then shows the equivalent CLI invocation.
// server/tasks/db-migrate.ts (placed in your Nitro server routes root)
import { defineTask } from "nitro/task";
export default defineTask({
meta: {
name: "db:migrate",
description: "Run database migrations",
},
async run({ payload }) {
console.log("Running migrations with payload:", payload);
// ... migration logic
return { result: "ok" };
},
});
# After `nitro build`, run the task:
npx nitro task run db:migrate --payload '{"env":"production"}'
cli/index.ts - Bootstraps the nitro CLI using citty, wires all subcommands via dynamic imports.cli/commands/ - Individual command implementations: dev, build, deploy, prepare, preview, docs, and the task sub-group.cli/commands/task/index.ts - Groups task list and task run under the task parent command.config/defaults.ts - Hardcoded default values for all Nitro config keys.config/loader.ts - Reads and merges nitro.config.ts / nuxt.config.ts from disk.config/update.ts - Mutates a live Nitro config after initial resolution (used by dev HMR).config/resolvers/ - One file per concern: paths, assets, storage, database, route-rules, unenv polyfills, tracing, tsconfig generation, etc.dev/app.ts - The H3 application used during development.dev/server.ts - Wraps srvx to run the dev server with HMR.dev/vfs.ts - Virtual file-system overlay for dev-mode generated files.prerender/prerender.ts - Crawls and statically renders all matching routes.prerender/utils.ts - URL normalisation and deduplication helpers for the prerender queue.presets/ - One subdirectory per deployment target, each exporting a NitroPreset object.runtime/ - Code that ends up inside the compiled server bundle (middleware, storage, cache, tasks).types/ - TypeScript-only barrel: config, hooks, fetch matchers, handler types, route-rules, build info, prerender, runner, module, srvx.utils/ - Shared helpers (logging, fs, rolldown plugin utilities).builder.ts - Orchestrates prepare → copyPublicAssets → build using Rolldown.global.ts - Augments global types and re-exports symbols needed at the top level.module.ts - defineNitroModule and the module resolution/execution pipeline.nitro.ts - createNitro: merges config, runs resolvers, instantiates hooks, returns the Nitro context.preview.ts - createDevServer wrapper for serving an already-built .output directory locally.routing.ts - Converts scanned handler files into H3 router entries.scan.ts - Glob-scans server/routes/, server/middleware/, server/plugins/ etc.task.ts - defineTask factory and the server-side task executor.vite.ts - Vite plugin factory that integrates Nitro's dev middleware into a Vite dev server."type": "commonjs", add "type": "module" to package.json or wrap Nitro imports behind a dynamic import().moduleResolution must be bundler or node16. Older node resolution breaks imports of .ts extension paths; set "moduleResolution": "bundler" in tsconfig.json.NITRO_PRESET not set in production. Without it Nitro falls back to node-server; ensure the env var is injected in your CI/CD pipeline before running nitro build.rolldown to the exact version in the upstream package.json to avoid subtle bundling breakage.unstorage driver auto-import. Storage drivers (Redis, S3, etc.) are resolved at runtime from unstorage; install the relevant driver packages separately (e.g. npm install unstorage ioredis) or the storage mounts will throw at startup.nitro task run --payload must be valid JSON strings; non-JSON values are silently ignored rather than throwing, which can cause confusing undefined payloads inside your task handler.I have purchased the `nuxt-nitropack` AVCP block. The source lives at `./nitro-src/`
relative to my project root. I also have `USAGE.md` in the same directory.
Upstream package: user@example.com
My project is a Node.js TypeScript application (ESM, moduleResolution: bundler).
Please do the following step by step:
1. Read `USAGE.md` in full before doing anything.
2. Install all required dependencies listed in the "Required dependencies" section.
3. Update my `tsconfig.json` with the path aliases and compiler options described in "Project setup".
4. Create a `scripts/build-server.ts` that imports `createNitro` from `./nitro-src/nitro.ts`
and `build`, `prepare`, `copyPublicAssets` from `./nitro-src/builder.ts`, wires them
together, and respects the `NITRO_PRESET` environment variable.
5. Add `dev`, `build`, and `preview` npm scripts to `package.json` using the `nitro` CLI.
6. Show me how to add a server task using `defineTask` and invoke it with `nitro task run`.
7. For every step, show the exact file path and full file content. Do not skip files.
Released under the MIT License (see source/LICENSE if present, or the upstream repository). Source: nitrojs/nitro - upstream npm package user@example.com.
This product’s unique contribution is clean room implementation of valuable code block into AVCP compatible standard.
The full install guide and integration prompts unlock after purchase.
Automation, Utilities & Developer Tools
Free