---
name: "nuxt-3-server-routes-nitro"
description: "Build blazing-fast serverless API routes, webhooks, and middleware using Nitro in Nuxt 3."
metadata:
  author: "Nuxt"
  version: "1.0.0"
  runtime_compatibility:
    - "codex"
    - "claude-code"
    - "cursor"
    - "windsurf"
triggers:
  - "write nuxt 3 server api route"
  - "cachedEventHandler nuxt nitro"
  - "readBody defineEventHandler"
permissions:
  fs_read: true
  fs_write: "workspace"
  shell_exec: false
  net_access: false
---

# Nuxt 3 Nitro Server Engine & API Route Handlers

Develops server routes with Nuxt 3 Nitro: authoring server/api/*.ts handlers using defineEventHandler, parsing query and body (getQuery, readBody), setting cookies, caching handlers with cachedEventHandler, and storage layers.

## When to Invoke
Invoke this skill whenever you need to:
- write nuxt 3 server api route
- cachedEventHandler nuxt nitro
- readBody defineEventHandler

## Execution SOP & Rules
1. Place route files in server/api/ or server/routes/ with HTTP method suffixes (.get.ts, .post.ts).
2. Define handler using defineEventHandler(async (event) => { ... }).
3. Parse inputs: const body = await readValidatedBody(event, schema.parse).
4. Throw structured errors using createError({ statusCode: 400, statusMessage: 'Bad Request' }).

## Verification Checklist
- Run local linting, syntax validation, and type-checks before reporting completion.
- Ensure all created or modified files adhere to workspace boundaries and avoid uncommitted secrets.
- Verify tests or build commands exit cleanly with return code 0.
