nitro
par sentry
Construisez et déployez des serveurs JavaScript universels avec Nitro v3. Utilisez lorsque vous travaillez avec nitro.config.ts, defineNitroConfig, defineHandler, defineConfig, server.ts…
npx skills add https://github.com/getsentry/junior --skill nitroBuild, configure, and deploy Nitro v3 applications using correct APIs and patterns.
Step 1: Classify the request
| Request type | Read first |
|---|---|
| API surface, handler signatures, imports, config options | references/api-surface.md |
| Setup, routing, caching, storage, plugins, frameworks, common patterns | references/common-use-cases.md |
| Build failures, runtime errors, deployment issues, migration from v2 | references/troubleshooting-workarounds.md |
Load only the reference(s) matching the request. If the task spans categories, load relevant files.
Step 2: Apply core guardrails
- Import
defineHandlerfrom"nitro", notdefineEventHandler(v2 API). - Import config helpers from subpaths:
"nitro/config","nitro/cache","nitro/storage","nitro/database","nitro/runtime-config","nitro/types". - Use web standard
event.req(Request) for body/headers — not v2 utilities likereadBodyorgetHeader. - Never return from middleware unless intentionally terminating the request.
- Only
GET/HEADrequests are cached bydefineCachedHandler; other methods bypass automatically. useDatabaseanddefineTaskrequire experimental feature flags.- Use
"nitro"package name, not"nitropack"(v2).
Step 3: Implement
- For new projects, use
defineConfigfrom"nitro"innitro.config.tsor addnitro()plugin from"nitro/vite"tovite.config.ts. - For server entry, export a web-compatible
fetch(Request): Responsehandler fromserver.ts, or useserver.node.tsfor Express/Fastify. - For filesystem routes, place handlers in
routes/orapi/with[param]for dynamic segments and.get.ts/.post.tsfor method-specific routes. - For caching, use
defineCachedHandlerfrom"nitro/cache"withmaxAgeandswroptions. - For storage, use
useStorage(namespace)from"nitro/storage"and configure drivers viastorageconfig. - For plugins, create files in
plugins/directory usingdefinePluginand hook intorequest,response,error, orclose. - For deployment, set
presetin config or useNITRO_PRESETenv var; Vercel/Netlify/Cloudflare are auto-detected.
Step 4: Validate
- Run
nitro devand verify routes respond correctly. - Run
nitro buildand check.output/server/contains expected files. - For cached routes, verify cache headers (
etag,cache-control) and 304 responses. - For storage, verify data persists across requests with configured driver.
- For deployment, verify the preset produces correct output format.
Step 5: Troubleshoot
defineEventHandler is not defined→ usedefineHandlerfrom"nitro"(v3 API).Cannot find module 'nitropack'→ rename to"nitro"in imports and package.json.- Route not matched → check file is in
routes/orapi/, or verifyroutesconfig mapping. - Middleware returning responses unexpectedly → ensure middleware does not return a value.
- For detailed diagnostics, read
references/troubleshooting-workarounds.md.