nitro
Build server-side applications with Nitro — the engine behind Nuxt server routes and Analog. Use when someone asks to "create an API server", "deploy to edge", "build server routes", "universal JavaScript server", "Nitro server", "deploy to Cloudflare Workers/Vercel/Netlify/Deno", or "isomorphic server". Covers API routes, middleware, storage, caching, WebSocket, task scheduling, and deployment to 15+ platforms with zero config changes.
What this skill does
# Nitro
## Overview
Nitro is a universal server engine — write your server code once, deploy it anywhere. Node.js, Deno, Bun, Cloudflare Workers, Vercel Edge, AWS Lambda, Netlify — same code, zero config changes. It powers Nuxt's server routes but works standalone for any API or full-stack app. File-based routing, built-in KV storage, auto-imports, and hot reload.
## When to Use
- Building APIs that need to deploy to multiple platforms
- Edge-first applications (Cloudflare Workers, Vercel Edge)
- Server-side companion for a frontend framework (not just Nuxt)
- Need built-in caching, storage, and task scheduling without external packages
- Migrating Express/Fastify to a platform-agnostic solution
## Instructions
### Setup
```bash
npx giget@latest nitro my-server
cd my-server
npm install
npm run dev
```
### File-Based API Routes
```
server/
├── routes/
│ ├── index.ts # GET /
│ ├── users/
│ │ ├── index.get.ts # GET /users
│ │ ├── index.post.ts # POST /users
│ │ └── [id].get.ts # GET /users/:id
│ └── health.ts # GET /health
├── middleware/
│ └── auth.ts # Runs before every request
├── plugins/
│ └── database.ts # Initialization logic
└── utils/
└── db.ts # Shared utilities (auto-imported)
```
```typescript
// server/routes/users/index.get.ts — List users
export default defineEventHandler(async (event) => {
const query = getQuery(event);
const page = Number(query.page) || 1;
const limit = Math.min(Number(query.limit) || 20, 100);
const users = await db.user.findMany({
skip: (page - 1) * limit,
take: limit,
});
return { users, page, limit };
});
// server/routes/users/index.post.ts — Create user
export default defineEventHandler(async (event) => {
const body = await readBody(event);
if (!body.email || !body.name) {
throw createError({ statusCode: 400, message: "Email and name required" });
}
const user = await db.user.create({ data: body });
setResponseStatus(event, 201);
return user;
});
// server/routes/users/[id].get.ts — Get user by ID
export default defineEventHandler(async (event) => {
const id = getRouterParam(event, "id");
const user = await db.user.findUnique({ where: { id } });
if (!user) {
throw createError({ statusCode: 404, message: "User not found" });
}
return user;
});
```
### Middleware
```typescript
// server/middleware/auth.ts — Auth middleware for all routes
export default defineEventHandler(async (event) => {
// Skip auth for public routes
const url = getRequestURL(event);
if (url.pathname === "/health" || url.pathname.startsWith("/auth/")) return;
const token = getHeader(event, "authorization")?.replace("Bearer ", "");
if (!token) {
throw createError({ statusCode: 401, message: "Unauthorized" });
}
const user = await verifyToken(token);
event.context.user = user;
});
```
### Built-in Storage (KV)
```typescript
// server/routes/cache/[key].ts — KV storage (works on every platform)
export default defineEventHandler(async (event) => {
const key = getRouterParam(event, "key")!;
if (event.method === "GET") {
const value = await useStorage("cache").getItem(key);
if (!value) throw createError({ statusCode: 404 });
return value;
}
if (event.method === "PUT") {
const body = await readBody(event);
await useStorage("cache").setItem(key, body);
return { ok: true };
}
});
```
### Deploy to Any Platform
```bash
# Build for different targets
NITRO_PRESET=cloudflare-pages npx nitro build
NITRO_PRESET=vercel npx nitro build
NITRO_PRESET=netlify npx nitro build
NITRO_PRESET=node-server npx nitro build
NITRO_PRESET=deno-server npx nitro build
NITRO_PRESET=bun npx nitro build
NITRO_PRESET=aws-lambda npx nitro build
```
## Examples
### Example 1: Build a REST API that deploys to Cloudflare Workers
**User prompt:** "Create a REST API with CRUD routes that runs on Cloudflare Workers edge."
The agent will create a Nitro project with file-based CRUD routes, middleware for auth, Cloudflare KV for storage, and deploy config for Workers.
### Example 2: API with caching and scheduled tasks
**User prompt:** "Build an API that caches expensive database queries and refreshes them every hour."
The agent will use Nitro's built-in storage for caching, defineTask for scheduled refreshes, and route-level cache headers.
## Guidelines
- **File naming = HTTP method** — `users.get.ts`, `users.post.ts`, `users.delete.ts`
- **`[param]` for dynamic routes** — `[id].get.ts` captures `:id`
- **`useStorage()` is universal** — KV that works on every platform (memory, Redis, Cloudflare KV)
- **`createError()` for HTTP errors** — structured error responses with status codes
- **Auto-imports** — `defineEventHandler`, `readBody`, `getQuery` are available without imports
- **Middleware runs on every request** — use path checks to skip public routes
- **`NITRO_PRESET` for deployment** — one codebase, 15+ deployment targets
- **`event.context` for request state** — pass data between middleware and handlers
Related in Backend & APIs
jfrog
IncludedInteract with the JFrog Platform via the JFrog CLI and REST/GraphQL APIs. Use this skill when the user wants to manage Artifactory repositories, upload or download artifacts, manage builds, configure permissions, manage users and groups, work with access tokens, configure JFrog CLI servers, search artifacts, manage properties, set up replication, manage JFrog Projects, run security audits or scans, look up CVE details, query exposures scan results from JFrog Advanced Security, manage release bundles and lifecycle operations, aggregate or export platform data, or perform any JFrog Platform administration task. Also use when the user mentions jf, jfrog, artifactory, xray, distribution, evidence, apptrust, onemodel, graphql, workers, mission control, curation, advanced security, exposures, or any JFrog product name.
cupynumeric-migration-readiness
IncludedPre-migration readiness assessor for porting NumPy to cuPyNumeric. Use BEFORE substantial porting work begins when the user asks whether code will scale on GPU, whether they should migrate to cuPyNumeric, which NumPy patterns transfer cleanly, what must be refactored before porting, or mentions pre-port assessment, scaling analysis, or refactor planning. Inspect the user's source code, look up NumPy usage, cross-reference the cuPyNumeric API support manifest, and distinguish distributed-scaling-friendly patterns from blockers such as unsupported APIs, scalar synchronization, host round-trips, Python/object-heavy control flow, shape/data-dependent branching, and in-place mutation hazards. Produce a verdict of READY, LIGHT REFACTOR, SIGNIFICANT REFACTOR, or NOT RECOMMENDED, with concrete refactor pointers.
alibabacloud-data-agent-skill
IncludedInvoke Alibaba Cloud Apsara Data Agent for Analytics via CLI to perform natural language-driven data analysis on enterprise databases. Data Agent for Analytics is an intelligent data analysis agent developed by Alibaba Cloud Database team for enterprise users. It automatically completes requirement analysis, data understanding, analysis insights, and report generation based on natural language descriptions. This tool supports: discovering data resources (instances/databases/tables) managed in DMS, initiating query or deep analysis sessions, real-time progress tracking, and retrieving analysis conclusions and generated reports. Use this Skill when users need to query databases, analyze data trends, generate data reports, ask questions in natural language, or mention "Data Agent", "data analysis", "database query", "SQL analysis", "data insights".
token-optimizer
IncludedReduce OpenClaw token usage and API costs through smart model routing, heartbeat optimization, budget tracking, and native 2026.2.15 features (session pruning, bootstrap size limits, cache TTL alignment). Use when token costs are high, API rate limits are being hit, or hosting multiple agents at scale. The 4 executable scripts (context_optimizer, model_router, heartbeat_optimizer, token_tracker) are local-only — no network requests, no subprocess calls, no system modifications. Reference files (PROVIDERS.md, config-patches.json) document optional multi-provider strategies that require external API keys and network access if you choose to use them. See SECURITY.md for full breakdown.
resend-cli
IncludedUse this skill when the task is specifically about operating Resend from an AI agent, terminal session, or CI job via the official resend CLI: installing/authenticating the CLI, sending/listing/updating/cancelling emails, batch sends, domains and DNS, webhooks and local listeners, inbound receiving, contacts, topics, segments, broadcasts, templates, API keys, profiles, or debugging Resend CLI/API failures. Trigger on mentions of Resend CLI, `resend`, `resend doctor`, `resend emails send`, `resend domains`, `resend webhooks listen`, `resend emails receiving`, or agent-friendly terminal automation.
alibabacloud-odps-maxframe-coding
IncludedUse this skill for MaxFrame SDK development and documentation navigation on Alibaba Cloud MaxCompute (ODPS). Helps answer MaxFrame API, concept, official example, and supported pandas API questions; create data processing programs; read/write MaxCompute tables; debug jobs (remote or local); and build custom DPE runtime images. Trigger when users mention MaxFrame, MaxCompute with MaxFrame, ODPS table processing, DPE runtime, MaxFrame docs/examples, DataFrame/Tensor operations, or GPU runtime setup. Works for both English and Chinese queries about Alibaba Cloud data processing with MaxFrame.