Generated banner for Nitro
Generated logo for Nitro

Nitro

Anthony FuCommunityCreated by Anthony Fu

  • Skill
  • Tool integration
  • Software development
  • MIT
  • No issues found

From the author

Nitro is the framework-agnostic server toolkit (powering Nuxt) for building and deploying web servers anywhere. Use when working with nitro.config, server routes/event handlers, route rules, caching, storage, tasks, websockets, or deploying to Node/Bun/Deno/Cloudflare/Vercel.
— the description by Anthony Fu

AutoGineer summary

Written by AutoGineer from the skill’s own files, not by the author

Nitro is a server toolkit designed to build and deploy web servers that run on Node.js, Bun, Deno, and various cloud platforms like Cloudflare, Vercel, and Netlify. It provides a unified codebase for server development, featuring filesystem-based routing, a built-in KV storage layer, caching mechanisms, and support for tasks, WebSockets, and OpenAPI documentation. Nitro v3 introduces significant changes including a package rename, the removal of auto-imports, and a shift toward web-standard H3 v2 APIs.

What it does

  • Provides filesystem-based routing with H3 v2 event handlers.
  • Manages server configuration and runtime settings via nitro.config.ts.
  • Handles caching and storage using an unstorage-based KV layer.
  • Supports on-demand and scheduled tasks, WebSockets, and SSE.
  • Generates OpenAPI specifications automatically from route metadata.
  • Enables deployment to multiple runtimes and platforms through presets.

When to use it

  • When building a web server that needs to be portable across different deployment environments.
  • When you require a unified toolkit for handling routing, storage, and caching in a server project.
  • When migrating existing server projects from Nitro v2 to v3.
  • When you need to implement server-side tasks, WebSockets, or OpenAPI documentation.

Advantages

  • Framework-agnostic design allows for use with or without other frameworks.
  • Deployment-agnostic architecture supports a wide range of runtimes and cloud providers.
  • Unified storage and caching layer simplifies data management.
  • Declarative route rules for handling redirects, headers, and CORS.
  • Built-in support for modern web standards via H3 v2.

Usage examples

“How do I define a basic server route in Nitro v3?”
You create a file in your server directory and export a handler using defineHandler from the nitro package.
“How do I access KV storage in my Nitro server?”
You use the useKV function imported from nitro/kv to interact with your configured storage mount points.
“What is the correct way to import Nitro utilities in v3?”
You must use explicit imports from specific subpaths like nitro, nitro/kv, or nitro/h3, as auto-imports are no longer supported.
“How do I configure public assets in Nitro?”
You define a publicAssets array in your nitro.config.ts file, specifying the directory and base URL for your assets.

Install

  1. Download the skill as a ZIP:

    https://mp-staging.autogineer.com/agent-skills/antfu/nitro/download
  2. Unzip it into the cross-client skills folder of your project:

    mkdir -p .agents/skills && unzip nitro.zip -d .agents/skills

Documentation by Anthony Fu

The skill is based on Nitro v3 (beta, 3.0.260903), generated at 2026-09-25.

Nitro is a framework-agnostic, deployment-agnostic server toolkit powered by H3 v2, unstorage, and Vite/Rolldown/Rollup. It powers Nuxt and works standalone. From one codebase it builds optimized output for Node.js, Bun, Deno, Cloudflare, Vercel, Netlify, and more.

Key capabilities:

  • Filesystem routing with H3 v2 event handlers, dynamic params, and method suffixes.

  • Route rules for declarative caching, headers, redirects, proxying, and CORS.

  • Caching layer (cached handlers/functions, SWR) on top of the unstorage KV layer.

  • Runtime config overridable via NITRO_* env vars.

  • Tasks (on-demand + scheduled/cron), WebSockets/SSE, a SQL database layer, and OpenAPI auto-docs.

  • Plugins & lifecycle hooks, custom renderer/server entry, and portable deployment presets.

Key v3 changes (vs. nitropack v2): the package is renamed nitropack → nitro with H3 v2 (web-standard Request/Response); auto-imports are removed (import everything explicitly); directory scanning is opt-in via serverDir; useStorage → useKV (nitro/kv) and the storage config option → kv; cache swr now defaults to false. If unsure about v2-vs-v3 APIs, read advanced-migration first.

Core

TopicDescriptionReference
RoutingFile-based routes, defineHandler, params, middleware, route rules, errorscore-routing
Configurationnitro.config.ts, defineConfig, key options, runtime configcore-configuration
Storageunstorage KV, mount points, drivers, dynamic mountscore-storage
CachedefineCachedHandler, defineCachedFunction, SWR, invalidationcore-cache
AssetsPublic assets, compression, server assets via storagecore-assets
RenderingRenderer (HTML/SSR), server entry, framework integrationcore-rendering

Features

TopicDescriptionReference
Plugins & HooksdefinePlugin, runtime lifecycle hooks, error capturefeatures-plugins
TasksOn-demand & scheduled (cron) tasks, runTaskfeatures-tasks
WebSocket & SSEdefineWebSocketHandler, pub/sub, namespaces, event streamsfeatures-websocket
DatabaseBuilt-in SQL layer via db0, useDatabase, connectorsfeatures-database
OpenAPIAuto spec from defineRouteMeta, Scalar/Swagger UIsfeatures-openapi

Advanced / Deployment

TopicDescriptionReference
Deployment PresetsRuntimes & providers, compatibility dates, platform integrationdeploy-presets
v2 → v3 MigrationPackage rename, nitro/* imports, H3 v2 API, preset changesadvanced-migration

Files

references/advanced-migration.md


name: migration description: Nitro v2 to v3 migration - package rename, subpath imports, H3 v2 API, and preset changes

Migration: Nitro v2 → v3

Nitro v3 has intentional breaking changes. This is the highest-value reference for agents whose training data assumes nitropack v2 / H3 v1 patterns.

Package & imports

The nitropack package is renamed to nitro.

- import { defineNitroConfig } from "nitropack/config"
+ import { defineConfig } from "nitro"

Runtime utils moved to dedicated nitro/* subpaths:

Capabilityv3 import
Handlers, config, plugins, errorsnitro (defineHandler, defineConfig, definePlugin, defineErrorHandler, HTTPError, defineWebSocketHandler, defineRouteMeta, defineServerEntry, serverFetch)
KV storagenitro/kv (useKV, formerly useStorage from nitro/storage)
Cachenitro/cache (defineCachedHandler, defineCachedFunction)
Runtime confignitro/runtime-config (useRuntimeConfig)
Databasenitro/database (useDatabase)
Tasksnitro/task (defineTask, runTask)
App / hooksnitro/app (useNitroApp, useNitroHooks, getRouteRules)
H3 utilitiesnitro/h3
Typesnitro/types
Vite pluginnitro/vite

Removed: nitropack/kit, nitropack/presets, nitropack/core (use nitro/builder). Use NitroModule from nitro/types instead of defineNitroModule.

Other renames:

  • defineNitroPlugin → definePlugin

  • defineNitroConfig → defineConfig

  • defineNitroErrorHandler → defineErrorHandler

  • Node.js minimum is now 20.

  • App config (app.config.ts + useAppConfig()) was removed — import a regular .ts module instead.

Auto-imports are removed

v2 auto-imported defineEventHandler, useStorage, useRuntimeConfig, defineCachedFunction, defineNitroPlugin, #imports, and your server/utils/. All gone in v3 — the imports option, #imports, and nitro-imports.d.ts no longer exist. Add explicit imports everywhere, including relative imports from your own utils/:

import { defineHandler, definePlugin, defineErrorHandler, HTTPError, serverFetch } from "nitro";
import { useKV } from "nitro/kv";
import { useRuntimeConfig } from "nitro/runtime-config";
import { defineCachedFunction, defineCachedHandler } from "nitro/cache";
import { useDatabase } from "nitro/database";
import { defineTask, runTask } from "nitro/task";
import { useNitroApp, useNitroHooks } from "nitro/app";
import { getQuery, getCookie } from "nitro/h3";

Server directory scanning is opt-in

srcDir is deprecated for serverDir, which defaults to false — nothing (routes/, api/, middleware/, plugins/, tasks/) is scanned until you set it. Set serverDir: "./server" (or "." for the v2 root layout; true = "server").

Storage & cache config renames

  • useStorage → useKV (nitro/storage → nitro/kv).

  • storage config option → kv; devStorage → kv inside $development (and $prerender).

  • Cache: swr now defaults to false (was true); persist cache by mounting a cache point under kv.

Internal server fetch

useNitroApp().localFetch → serverFetch from nitro (returns a web Response). There is also a fetch export routing absolute (/) paths to the server.

Route rule types

NitroRouteConfig/NitroRouteRules are deprecated for RouteRuleConfig/RouteRules (from nitro/types). redirect, proxy, cors, headers, cache, swr are now defined by h3-rules; isr, prerender, static remain Nitro-specific. There is no auth/basicAuth route rule.

H3 v2 API

H3 v2 is built on web standards (URL, Headers, Request, Response). All H3 utils import from nitro/h3.

Return / throw, don't send
- import { send, sendRedirect, sendStream } from "nitro/h3"
- send(event, value); sendStream(event, stream); sendRedirect(event, loc, code)
+ import { redirect } from "nitro/h3"
+ return value
+ return stream
+ return redirect(event, loc, code)

Also: sendError → throw createError/HTTPError; sendNoContent → return noContent(event); sendProxy → return proxy(event, target).

Event shape

event.web → event.req (a web Request). event.node.{req,res} only exists on Node.

- const body = await readBody(event)
+ const body = await event.req.json()   // or .text() / .formData(); event.req.body for the stream
Headers (always plain strings)
- getHeader(event, "x-foo"); setHeader(event, "x-foo", "bar"); getResponseStatus(event)
+ event.req.headers.get("x-foo")
+ event.res.headers.set("x-foo", "bar")
+ event.res.status
Handlers & errors
- import { eventHandler, defineEventHandler, createError } from "nitro/h3"
+ import { defineHandler, HTTPError } from "nitro"
+ throw new HTTPError({ status: 404, message: "Not found" })
+ HTTPError.isError(error)

lazyEventHandler → defineLazyEventHandler; useBase → withBase. Node utils: defineNodeListener/toNodeListener/fromNodeMiddleware → defineNodeHandler/toNodeHandler/fromNodeHandler.

defineEventHandler/createError still work in many places (re-exported), but prefer the v3 names: defineHandler and HTTPError.

Cloudflare bindings

- const binding = event.context.cloudflare.env.MY_BINDING
+ const { env } = event.req.runtime.cloudflare
+ const binding = env.MY_BINDING

Preset renames

v2v3
nodenode_middleware (export is now middleware)
cloudflare, cloudflare_worker, cloudflare_module_legacycloudflare_module
deno-server-legacy / denodeno_server (Deno v2) / deno_deploy
netlify-buildernetlify or netlify_edge
vercel-edgevercel (Fluid compute)
azure, azure_functionsazure_swa
firebasefirebase_app_hosting
iisiis_handler
edgio, cli, service_workerremoved/discontinued

Hooks

If you accessed useNitroApp().hooks outside a plugin it may be undefined — use useNitroHooks() to guarantee an instance.

Key Points

  • Replace nitropack with nitro and split imports into nitro/* subpaths.

  • Auto-imports are gone — import everything explicitly; set serverDir or nothing is scanned.

  • useStorage→useKV (nitro/kv), storage→kv, devStorage→$development.kv.

  • Handlers return/throw; use event.req.json() and web Headers (no send*/readBody/getHeader).

  • Use HTTPError instead of createError; definePlugin/defineHandler/defineConfig/defineErrorHandler instead of v2 names.

  • Cloudflare bindings moved to event.req.runtime.cloudflare.env.

  • Many presets were renamed/removed — update preset accordingly.

<!-- Source references: - https://nitro.build/docs/migration - https://h3.dev -->

Requirements and compatibility

Works with: Claude Code, Claude apps, OpenAI Codex, GitHub Copilot, Cursor, Gemini CLI, Kiro, OpenCode, Goose, Amp, Roo Code, JetBrains Junie, Factory Droid, Devin (ex-Windsurf), Mistral Vibe, OpenHands, Letta

“Works with” means the tool reads the open Agent Skills format; a skill written for one tool may use features others lack.

Security

No issues found by our static scan· No issues found

A static scan is not a guarantee. Skills are third-party content: review a skill before you let an agent use it.

Attribution and licence

Created by
Anthony Fu
Publisher
Anthony Fu (Community)
Source
antfu/skills · skills/nitro · commit f63e9ec
Licence
MIT License (redistribution allowed)
  • LICENSE (added by AutoGineer from LICENSE.md)
  • ATTRIBUTION.md (written by AutoGineer)
Synced

AutoGineer is not affiliated with or endorsed by Anthony Fu.

Download ZIP

The ZIP holds the skill’s files, its licence files and an ATTRIBUTION.md. Download nitro.zip