> nitropack
You are an expert in Nitro (NitroJS), the universal server engine powering Nuxt, Analog, and SolidStart. You help developers build portable server applications with file-based routing, auto-imports, server middleware, storage abstraction, caching, WebSocket support, and deployment to 20+ platforms (Node.js, Deno, Bun, Cloudflare Workers, Vercel, Netlify, AWS Lambda) — with zero configuration changes between environments.
curl "https://skillshub.wtf/TerminalSkills/skills/nitropack?format=md"Nitro — Universal Server Engine
You are an expert in Nitro (NitroJS), the universal server engine powering Nuxt, Analog, and SolidStart. You help developers build portable server applications with file-based routing, auto-imports, server middleware, storage abstraction, caching, WebSocket support, and deployment to 20+ platforms (Node.js, Deno, Bun, Cloudflare Workers, Vercel, Netlify, AWS Lambda) — with zero configuration changes between environments.
Core Capabilities
Server Routes
// server/routes/users/[id].get.ts — File-based API routes
export default defineEventHandler(async (event) => {
const id = getRouterParam(event, "id");
const user = await useStorage("db").getItem(`users:${id}`);
if (!user) throw createError({ statusCode: 404, message: "User not found" });
return user;
});
// server/routes/users.post.ts
export default defineEventHandler(async (event) => {
const body = await readBody(event);
if (!body.name || !body.email) {
throw createError({ statusCode: 400, message: "Name and email required" });
}
const id = crypto.randomUUID();
await useStorage("db").setItem(`users:${id}`, { id, ...body, createdAt: Date.now() });
setResponseStatus(event, 201);
return { id, ...body };
});
// server/routes/health.get.ts
export default defineEventHandler(() => ({ status: "ok", timestamp: Date.now() }));
Middleware and Utils
// server/middleware/auth.ts — Runs on every request
export default defineEventHandler(async (event) => {
const path = getRequestURL(event).pathname;
if (path.startsWith("/api/public")) return;
const token = getHeader(event, "authorization")?.replace("Bearer ", "");
if (!token) throw createError({ statusCode: 401, message: "Unauthorized" });
event.context.user = await verifyToken(token);
});
// server/utils/db.ts — Auto-imported utilities
export function getUserById(id: string) {
return useStorage("db").getItem(`users:${id}`);
}
// server/middleware/cache.ts
export default defineEventHandler(async (event) => {
if (getMethod(event) === "GET") {
setResponseHeaders(event, { "Cache-Control": "s-maxage=60, stale-while-revalidate=300" });
}
});
Storage & Tasks
// nitro.config.ts
export default defineNitroConfig({
storage: {
db: { driver: "redis", url: process.env.REDIS_URL },
cache: { driver: "memory" },
fs: { driver: "fs", base: "./data" },
},
scheduledTasks: {
"*/5 * * * *": ["cleanup"], // Every 5 minutes
"0 9 * * *": ["daily-report"],
},
});
// server/tasks/cleanup.ts
export default defineTask({
meta: { name: "cleanup", description: "Clean expired sessions" },
run: async () => {
const keys = await useStorage("db").getKeys("sessions:");
// ... cleanup logic
return { result: `Cleaned ${deleted} sessions` };
},
});
Installation
npx giget nitro my-app
cd my-app && npm install
npm run dev # Dev server on :3000
npm run build # Build for current preset
NITRO_PRESET=cloudflare-pages npm run build # Build for Cloudflare
Best Practices
- File-based routing —
server/routes/maps to URLs;[param].tsfor dynamic,.get.ts/.post.tsfor methods - Auto-imports —
defineEventHandler,useStorage,createErrorauto-imported; no import statements needed - Universal deployment — Same code deploys everywhere; change
NITRO_PRESETto switch platform - Storage abstraction — Use
useStorage()for Redis, KV, FS, S3; swap drivers without changing code - Server tasks — Define cron-like tasks in
server/tasks/; scheduled vianitro.config.ts - H3 under the hood — Nitro uses H3 for HTTP handling; ultralight, tree-shakeable, edge-compatible
- Cached routes — Use
defineCachedEventHandlerfor automatic response caching; TTL-based invalidation - WebSocket support — Use
defineWebSocketHandlerfor real-time features; works across all platforms
> related_skills --same-repo
> zustand
You are an expert in Zustand, the small, fast, and scalable state management library for React. You help developers manage global state without boilerplate using Zustand's hook-based stores, selectors for performance, middleware (persist, devtools, immer), computed values, and async actions — replacing Redux complexity with a simple, un-opinionated API in under 1KB.
> zoho
Integrate and automate Zoho products. Use when a user asks to work with Zoho CRM, Zoho Books, Zoho Desk, Zoho Projects, Zoho Mail, or Zoho Creator, build custom integrations via Zoho APIs, automate workflows with Deluge scripting, sync data between Zoho apps and external systems, manage leads and deals, automate invoicing, build custom Zoho Creator apps, set up webhooks, or manage Zoho organization settings. Covers Zoho CRM, Books, Desk, Projects, Creator, and cross-product integrations.
> zod
You are an expert in Zod, the TypeScript-first schema declaration and validation library. You help developers define schemas that validate data at runtime AND infer TypeScript types at compile time — eliminating the need to write types and validators separately. Used for API input validation, form validation, environment variables, config files, and any data boundary.
> zipkin
Deploy and configure Zipkin for distributed tracing and request flow visualization. Use when a user needs to set up trace collection, instrument Java/Spring or other services with Zipkin, analyze service dependencies, or configure storage backends for trace data.