跳到正文
Skillpedia
API 与服务器(后端)6.0k · #14440

nitro

它能做什么

这项技能说明如何使用 Nitro 构建网页服务器。Nitro 是一个可在许多托管服务上运行的服务器工具包。适合构建 API 或网站后端部分的开发者。

适用场景

  • ✓当你在 Nitro 项目中构建服务器路由或 API 端点时。
  • ✓当你想为服务器添加缓存、定时任务或存储时。
  • ✓当你想把服务器部署到 Node、Cloudflare 或 Vercel 等平台时。

技能链接

https://github.com/antfu/skills/blob/main/skills/nitro/SKILL.md

复制后粘贴给你的 AI(Claude、ChatGPT 或 Cursor),让它按照说明操作。

使用方法

最简单的方法:复制下面的消息,粘贴给你的 AI。它会读取这个技能并按说明操作。

可直接粘贴的消息

请用这个技能帮我:https://github.com/antfu/skills/blob/main/skills/nitro/SKILL.md 阅读该链接中的 SKILL.md 文件,并在我的任务中按照它的说明来做。
想让你的 AI 自己找到这样的技能吗?安装免费的 Skillpedia MCP:只需一行,每次任务前它都会在 15,000+ 个技能中搜索。1 分钟完成安装 →

可以这样问 AI

“请帮我设置一个 Nitro 服务器,包含一个会缓存结果的 API 路由,并部署到 Cloudflare。”

每周 5 个新技能,1 分钟读完。

工作原理

智能体遵循 Nitro 关于路由、设置和部署的指导,在新旧版本规则不同之处,使用较新版本的规则。

技术内容(原始 SKILL.md)

作者在 GitHub 上的英文原文。

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

Topic Description Reference
Routing File-based routes, defineHandler, params, middleware, route rules, errors core-routing
Configuration nitro.config.ts, defineConfig, key options, runtime config core-configuration
Storage unstorage KV, mount points, drivers, dynamic mounts core-storage
Cache defineCachedHandler, defineCachedFunction, SWR, invalidation core-cache
Assets Public assets, compression, server assets via storage core-assets
Rendering Renderer (HTML/SSR), server entry, framework integration core-rendering

Features

Topic Description Reference
Plugins & Hooks definePlugin, runtime lifecycle hooks, error capture features-plugins
Tasks On-demand & scheduled (cron) tasks, runTask features-tasks
WebSocket & SSE defineWebSocketHandler, pub/sub, namespaces, event streams features-websocket
Database Built-in SQL layer via db0, useDatabase, connectors features-database
OpenAPI Auto spec from defineRouteMeta, Scalar/Swagger UIs features-openapi

Advanced / Deployment

Topic Description Reference
Deployment Presets Runtimes & providers, compatibility dates, platform integration deploy-presets
v2 → v3 Migration Package rename, nitro/* imports, H3 v2 API, preset changes advanced-migration
常见问题

这是针对最新版 Nitro 的吗?

是的。它基于 Nitro v3,并会说明旧版本的不同之处。

Nitro 能与 Nuxt 一起使用吗?

能。Nitro 是 Nuxt 背后的服务器引擎,它也可以单独使用。

支持哪些托管服务?

指导涵盖许多选项,包括 Node、Bun、Deno、Cloudflare 和 Vercel。

详情

作者的原始描述

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.

repo: antfu/skills

热度

GitHub 星标
6.0k
排名
#14440
许可证
MIT
更新时间
2026/10/30

这个技能有用吗?

0

登录 后即可投票。

评论

  • …

同一仓库的更多技能

相似技能