[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M71EHYH0MCP4YN0807V9MAA1":3,"skill-same:01M71EHYH0MCP4YN0807V9MAA1":208},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":16,"categories":17,"keywords":23,"publishedAt":44,"linkOnly":45,"markdownContent":46,"markdownBody":47,"frontMatter":48,"refName":186,"commitSha":187,"skillDirectory":188,"forksCount":14,"repositoryHtmlUrl":189,"repositoryHomepageUrl":6,"ownerHtmlUrl":190,"ownerBlogUrl":191,"ownerDescription":192,"updatedAt":193,"install":194,"resources":207},"01M71EHYH0MCP4YN0807V9MAA1","vercel-functions",null,"Vercel Functions expert guidance — Serverless Functions, Edge Functions, Fluid Compute, streaming, Cron Jobs, and runtime configuration. Use when configuring, debugging, or optimizing server-side code running on Vercel.","patinaproject\u002Fskills","patinaproject","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F229996889?v=4","01M71E58JKTDNY1138WYZK44TR","Patina Project","01M71E58K5GH4K16MV6A8BQ6NZ",1,"MIT","https:\u002F\u002Fgithub.com\u002Fpatinaproject\u002Fskills\u002Fblob\u002Fmain\u002F.agents\u002Fskills\u002Fvercel-functions\u002FSKILL.md",[18],{"categoryNo":19,"categoryName":20,"taxonomyType":21,"taxonomyTypeDesc":22},"01JBSEEDCAT000000000000010","后端与接口","SCENARIO","使用场景",[24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43],"vercel","vercel functions","functions","logs","express","@vercel\u002Fpostgres","image","apps","loop","retries","local","socket","time","neon","move","expert","project","cold","app","shared","2026-11-10 10:12:30",false,"---\nname: vercel-functions\ndescription: Vercel Functions expert guidance — Serverless Functions, Edge Functions, Fluid Compute, streaming, Cron Jobs, and runtime configuration. Use when configuring, debugging, or optimizing server-side code running on Vercel.\nmetadata:\n  priority: 8\n  docs:\n    - \"https:\u002F\u002Fvercel.com\u002Fdocs\u002Ffunctions\"\n    - \"https:\u002F\u002Fvercel.com\u002Fdocs\u002Ffunctions\u002Fruntimes\"\n    - \"https:\u002F\u002Fvercel.com\u002Fdocs\u002Ffunctions\u002Fwebsockets\"\n  sitemap: \"https:\u002F\u002Fvercel.com\u002Fsitemap.xml\"\n  pathPatterns:\n    - 'api\u002F**\u002F*.*'\n    - 'pages\u002Fapi\u002F**'\n    - 'src\u002Fpages\u002Fapi\u002F**'\n    - 'app\u002F**\u002Froute.*'\n    - 'src\u002Fapp\u002F**\u002Froute.*'\n    - 'apps\u002F*\u002Fapi\u002F**\u002F*.*'\n    - 'apps\u002F*\u002Fapp\u002F**\u002Froute.*'\n    - 'apps\u002F*\u002Fsrc\u002Fapp\u002F**\u002Froute.*'\n    - 'apps\u002F*\u002Fpages\u002Fapi\u002F**'\n    - 'vercel.json'\n    - 'apps\u002F*\u002Fvercel.json'\n  bashPatterns:\n    - '\\bvercel\\s+dev\\b'\n    - '\\bvercel\\s+logs\\b'\n  importPatterns:\n    - 'ws'\n    - 'socket.io'\n    - 'socket.io-client'\n  promptSignals:\n    phrases:\n      - \"websocket\"\n      - \"websockets\"\n      - \"web socket\"\n      - \"socket.io\"\n      # Polling is the classic technique people reach for when they think Vercel\n      # lacks websockets. We intentionally do NOT trigger on named third-party\n      # services (Pusher, PubNub, Ably) — those are deliberate choices, not a\n      # signal that someone is working around a missing feature.\n      - \"long polling\"\n      - \"long-polling\"\n    allOf: []\n    anyOf:\n      - \"realtime\"\n      - \"bidirectional\"\n      - \"ws server\"\n      - \"polling\"\n      - \"server-sent events\"\n    noneOf: []\n    minScore: 6\nvalidate:\n  -\n    pattern: export\\s+default\\s+function\n    message: 'Use named exports (GET, POST, PUT, DELETE) instead of default export for route handlers'\n    severity: error\n    # Skip on App Router page \u002F layout \u002F loading \u002F error \u002F not-found \u002F sitemap \u002F template \u002F default files,\n    # which require a default export by Next.js convention. Detected via the 'use client' directive,\n    # an App Router config export (metadata, dynamic, revalidate, fetchCache, runtime), an `export default\n    # function` whose name matches an App Router file (Page \u002F Layout \u002F Loading \u002F etc.), or any JSX\n    # element with a capitalised component tag — all signals that the file is a page-style file rather\n    # than a route handler. See anthropics\u002Fclaude-code#54989.\n    skipIfFileContains: \"(?:^|\\\\n)\\\\s*['\\\"]use\\\\s+client['\\\"]|export\\\\s+const\\\\s+(?:metadata|dynamic|revalidate|fetchCache|runtime)\\\\b|export\\\\s+default\\\\s+(?:async\\\\s+)?function\\\\s+\\\\w*(?:Page|Layout|Loading|Error|NotFound|Sitemap|Template|Default|sitemap|robots|opengraph|manifest)\\\\b|\u003C[A-Z][A-Za-z0-9]*|\\\\{\\\\s*children\\\\s*[,}:]|MetadataRoute\\\\.|from\\\\s+['\\\"]next\u002F(?:font|image|link|navigation|headers|cookies)['\\\"]\"\n  -\n    pattern: NextApiRequest|NextApiResponse\n    message: 'NextApiRequest\u002FNextApiResponse are Pages Router types — use Web API Request\u002FResponse'\n    severity: error\n  -\n    pattern: 'from\\s+[''\"](openai|@anthropic-ai\u002Fsdk|anthropic)[''\"]|new\\s+(OpenAI|Anthropic)\\('\n    message: 'Direct AI provider SDK detected in route handler. Use the Vercel AI SDK for streaming, tools, and provider abstraction.'\n    severity: recommended\n    upgradeToSkill: ai-sdk\n    upgradeWhy: 'Replace vendor-locked provider SDKs with @ai-sdk\u002Fopenai or @ai-sdk\u002Fanthropic for unified streaming and tool support.'\n    skipIfFileContains: '@ai-sdk\u002F|from\\s+[''\"](ai)[''\"]|import.*from\\s+[''\"](ai)[''\"]|streamText|generateText'\n  -\n    pattern: 'setTimeout\\s*\\(|setInterval\\s*\\(|await\\s+new\\s+Promise\\s*\\([^)]*setTimeout'\n    message: 'Long-running or polling logic detected in a serverless handler. Functions have execution time limits.'\n    severity: recommended\n    upgradeToSkill: workflow\n    upgradeWhy: 'Move delayed\u002Fpolling logic to Vercel Workflow for durable execution with pause, resume, retries, and crash safety.'\n    skipIfFileContains: 'use workflow|use step|@vercel\u002Fworkflow'\n  -\n    pattern: 'writeFile(Sync)?\\(|createWriteStream\\(|from\\s+[''\"](multer|formidable)[''\"]|fs\\.writeFile'\n    message: 'Local filesystem write detected. Serverless functions have ephemeral, read-only filesystems.'\n    severity: error\n    upgradeToSkill: vercel-storage\n    upgradeWhy: 'Replace local filesystem writes with Vercel Blob, Neon, or Upstash for persistent, platform-native storage.'\n    skipIfFileContains: '@vercel\u002Fblob|@upstash\u002F|@neondatabase\u002F'\n  -\n    pattern: 'export\\s+(async\\s+)?function\\s+(GET|POST|PUT|PATCH|DELETE)\\b'\n    message: 'Route handler has no observability instrumentation. Add logging and error tracking for production debugging.'\n    severity: warn\n    skipIfFileContains: 'console\\.error|logger\\.|captureException|Sentry|@vercel\u002Fotel|withTracing'\n  -\n    pattern: 'from\\s+[''\"\"](lru-cache|node-cache|memory-cache)[''\"\"]|new\\s+(LRUCache|NodeCache|Map)\\(\\s*\\).*cache'\n    message: 'In-process memory cache detected in serverless function. Process memory is not shared across invocations.'\n    severity: recommended\n    upgradeToSkill: runtime-cache\n    upgradeWhy: 'Replace in-process caches with Vercel Runtime Cache (getCache from @vercel\u002Ffunctions) for region-aware caching that persists across invocations.'\n    skipIfFileContains: 'getCache|from\\s+[''\"\"]\\@vercel\u002Ffunctions[''\"\"]'\n  -\n    pattern: 'maxRetries\\s*[=:]|retryCount\\s*[=:]|retry\\s*\\(\\s*|for\\s*\\([^)]*retry|while\\s*\\([^)]*retry'\n    message: 'Manual retry logic detected. Use Vercel Workflow SDK for automatic retries with durable execution.'\n    severity: recommended\n    upgradeToSkill: workflow\n    upgradeWhy: 'Replace manual retry loops with Workflow SDK steps that provide automatic retries, crash safety, and observability.'\n    skipIfFileContains: 'use workflow|use step|@vercel\u002Fworkflow|from\\s+[''\"\"](workflow)[''\"\"]'\n  -\n    pattern: 'from\\s+[''\"](express)[''\"\"]|require\\s*\\(\\s*[''\"](express)[''\"\"\\)]'\n    message: 'Express.js detected in a Vercel project. Vercel Functions use the Web Request\u002FResponse API — Express middleware, req\u002Fres, and app.listen() do not work in serverless.'\n    severity: recommended\n    upgradeToSkill: vercel-functions\n    upgradeWhy: 'Replace Express with Next.js route handlers (export async function GET\u002FPOST) or Vercel Functions using the Web Request\u002FResponse API.'\n    skipIfFileContains: 'export\\s+(async\\s+)?function\\s+(GET|POST|PUT|PATCH|DELETE)|from\\s+[''\"\"](next\u002Fserver|@vercel\u002Ffunctions)[''\"\"]'\nretrieval:\n  aliases:\n    - serverless functions\n    - api routes\n    - edge functions\n    - lambda\n    - websockets\n    - socket.io\n  intents:\n    - create serverless function\n    - configure function runtime\n    - optimize cold starts\n    - add api route\n    - serve a websocket connection\n  entities:\n    - Serverless Functions\n    - Edge Functions\n    - Fluid Compute\n    - streaming\n    - WebSockets\n    - Cron Jobs\nchainTo:\n  -\n    pattern: 'from\\s+[''\\\"](openai|@anthropic-ai\u002Fsdk|anthropic)[''\"]|new\\s+(OpenAI|Anthropic)\\('\n    targetSkill: ai-sdk\n    message: 'Direct AI provider SDK in route handler — loading AI SDK guidance for unified streaming and tool support.'\n  -\n    pattern: 'setTimeout\\s*\\(|setInterval\\s*\\(|await\\s+new\\s+Promise\\s*\\([^)]*setTimeout'\n    targetSkill: workflow\n    message: 'Long-running or polling logic in serverless handler — loading Workflow SDK for durable execution.'\n  -\n    pattern: 'writeFile(Sync)?\\(|createWriteStream\\(|from\\s+[''\\\"](multer|formidable)[''\"]|fs\\.writeFile'\n    targetSkill: vercel-storage\n    message: 'Local filesystem write in serverless function — loading Vercel Storage guidance for platform-native persistence.'\n  -\n    pattern: 'from\\s+[''\"\"]@vercel\u002F(postgres|kv)[''\"\"]'\n    targetSkill: vercel-storage\n    message: '@vercel\u002Fpostgres and @vercel\u002Fkv are sunset — loading Vercel Storage guidance for Neon and Upstash migration.'\n  -\n    pattern: 'generateObject\\s*\\(|streamObject\\s*\\(|toDataStreamResponse|maxSteps\\b|CoreMessage\\b'\n    targetSkill: ai-sdk\n    message: 'Deprecated AI SDK v5 API detected — loading AI SDK v6 guidance for migration.'\n  -\n    pattern: 'while\\s*\\(\\s*true\\s*\\)\\s*\\{|for\\s*\\(\\s*;\\s*;\\s*\\)\\s*\\{|setInterval\\s*\\(\\s*async'\n    targetSkill: workflow\n    message: 'Polling loop in serverless function detected — loading Workflow SDK for durable, crash-safe execution with pause\u002Fresume.'\n    skipIfFileContains: \"use workflow|use step|from\\\\s+['\\\"]workflow['\\\"]\"\n  -\n    pattern: \"from\\\\s+['\\\"]express['\\\"]|require\\\\s*\\\\(\\\\s*['\\\"]express['\\\"]\"\n    targetSkill: vercel-functions\n    message: 'Express.js detected — loading Vercel Functions guidance for Web Request\u002FResponse API route handlers that replace Express middleware and routing.'\n    skipIfFileContains: \"export\\\\s+(async\\\\s+)?function\\\\s+(GET|POST|PUT|PATCH|DELETE)\"\n  -\n    pattern: 'from\\s+[''\"\"](lru-cache|node-cache|memory-cache)[''\"\"]|new\\s+(LRUCache|NodeCache|Map)\\(\\s*\\).*cache'\n    targetSkill: runtime-cache\n    message: 'In-process memory cache in serverless function — loading Runtime Cache guidance for region-aware caching that persists across invocations.'\n    skipIfFileContains: 'getCache|from\\s+[''\"\"]\\@vercel\u002Ffunctions[''\"\"]'\n  -\n    pattern: 'maxRetries\\s*[=:]|retryCount\\s*[=:]|retry\\s*\\(\\s*|for\\s*\\([^)]*retry|while\\s*\\([^)]*retry'\n    targetSkill: workflow\n    message: 'Manual retry logic in serverless handler — loading Workflow SDK guidance for automatic retries with durable execution.'\n    skipIfFileContains: 'use workflow|use step|@vercel\u002Fworkflow|from\\s+[''\"\"](workflow)[''\"\"]'\n\n---\n\n# Vercel Functions\n\nYou are an expert in Vercel Functions — the compute layer of the Vercel platform.\n\n## Function Types\n\n### Serverless Functions (Node.js)\n- Full Node.js runtime, all npm packages available\n- Default for Next.js API routes, Server Actions, Server Components\n- Cold starts: 800ms–2.5s (with DB connections)\n- Max duration: 10s (Hobby), 300s (Pro default), 800s (Fluid Compute Pro\u002FEnterprise)\n\n```ts\n\u002F\u002F app\u002Fapi\u002Fhello\u002Froute.ts\nexport async function GET() {\n  return Response.json({ message: 'Hello from Node.js' })\n}\n```\n\n### Edge Functions (V8 Isolates)\n- Lightweight V8 runtime, Web Standard APIs only\n- Ultra-low cold starts (\u003C1ms globally)\n- Limited API surface (no full Node.js)\n- Best for: auth checks, redirects, A\u002FB testing, simple transformations\n\n```ts\n\u002F\u002F app\u002Fapi\u002Fhello\u002Froute.ts\nexport const runtime = 'edge'\n\nexport async function GET() {\n  return new Response('Hello from the Edge')\n}\n```\n\n### Bun Runtime (Public Beta)\n\nAdd `\"bunVersion\": \"1.x\"` to `vercel.json` to run Node.js functions on Bun instead. ~28% lower latency for CPU-bound workloads. Supports Next.js, Express, Hono, Nitro.\n\n### Rust Runtime (Public Beta)\n\nRust functions run on Fluid Compute with HTTP streaming and Active CPU pricing. Built on the community Rust runtime. Supports environment variables up to 64 KB.\n\n### Node.js 24 LTS\n\nNode.js 24 LTS is now GA on Vercel for both builds and functions. Features V8 13.6, global `URLPattern`, Undici v7 for faster `fetch()`, and npm v11.\n\n### Choosing Runtime\n\n| Need | Runtime | Why |\n|------|---------|-----|\n| Full Node.js APIs, npm packages | `nodejs` | Full compatibility |\n| Lower latency, CPU-bound work | `nodejs` + Bun | ~28% latency reduction |\n| Ultra-low latency, simple logic | `edge` | \u003C1ms cold start, global |\n| Database connections, heavy deps | `nodejs` | Edge lacks full Node.js |\n| Auth\u002Fredirect at the edge | `edge` | Fastest response |\n| AI streaming | Either | Both support streaming |\n| Systems-level performance | `rust` (beta) | Native speed, Fluid Compute |\n\n## Fluid Compute\n\nFluid Compute is the unified execution model for all Vercel Functions (both Node.js and Edge).\n\nKey benefits:\n- **Optimized concurrency**: Multiple invocations on a single instance — up to 85% cost reduction for high-concurrency workloads\n- **Extended durations**: Default 300s for all plans; up to 800s on Pro\u002FEnterprise\n- **Active CPU pricing**: Charges only while CPU is actively working, not during idle\u002Fawait time. Enabled by default for all plans. Memory-only periods billed at a significantly lower rate.\n- **Background processing**: `waitUntil` \u002F `after` for post-response tasks\n- **Dynamic scaling**: Automatic during traffic spikes\n- **Bytecode caching**: Reduces cold starts via Rust-based runtime with pre-compiled function code\n- **Multi-region failover**: Default for Enterprise when Fluid is activated\n\n### Instance Sizes\n\n| Size | CPU | Memory |\n|------|-----|--------|\n| Standard (default) | 1 vCPU | 2 GB |\n| Performance | 2 vCPU | 4 GB |\n\nHobby projects use Standard CPU. The Basic CPU instance has been removed.\n\n### Background Processing with `waitUntil`\n\n```ts\n\u002F\u002F Continue work after sending response\nimport { waitUntil } from '@vercel\u002Ffunctions'\n\nexport async function POST(req: Request) {\n  const data = await req.json()\n\n  \u002F\u002F Send response immediately\n  const response = Response.json({ received: true })\n\n  \u002F\u002F Continue processing in background\n  waitUntil(async () => {\n    await processAnalytics(data)\n    await sendNotification(data)\n  })\n\n  return response\n}\n```\n\n### Next.js `after` (equivalent)\n\n```ts\nimport { after } from 'next\u002Fserver'\n\nexport async function POST(req: Request) {\n  const data = await req.json()\n\n  after(async () => {\n    await logToAnalytics(data)\n  })\n\n  return Response.json({ ok: true })\n}\n```\n\n## Streaming\n\nZero-config streaming on **both runtimes**, including Server-Sent Events (SSE). Essential for AI applications.\n\n> **You do NOT need `runtime = 'edge'` for streaming or SSE.** Streaming responses (`ReadableStream`, `text\u002Fevent-stream`) work on the default Node.js runtime — this is a common misconception. Stay on Node.js (Fluid Compute) so you keep full Node.js APIs, npm packages, and longer durations; Edge offers no streaming advantage here.\n\n```ts\nexport async function POST(req: Request) {\n  const encoder = new TextEncoder()\n  const stream = new ReadableStream({\n    async start(controller) {\n      for (const chunk of data) {\n        controller.enqueue(encoder.encode(chunk))\n        await new Promise(r => setTimeout(r, 100))\n      }\n      controller.close()\n    },\n  })\n\n  return new Response(stream, {\n    headers: { 'Content-Type': 'text\u002Fevent-stream' },\n  })\n}\n```\n\nFor AI streaming, use the AI SDK's `toUIMessageStreamResponse()` (for chat UIs with `useChat`) which handles SSE formatting automatically.\n\n## WebSockets\n\nVercel Functions can hold open bidirectional WebSocket connections — use them for realtime features like interactive AI streaming, chat, and collaborative apps. There is **no separate WebSocket-server product and no third-party service (Pusher, Ably, etc.) required** — it runs on Vercel Functions directly. Requires **Fluid Compute**, which is the default for new projects.\n\n**How it works**: a WebSocket starts as an HTTP `GET` with an `Upgrade` header, so it passes through the same Routing Middleware, rewrites, Firewall rules, and rate limits as any other request. After the upgrade, the connection is pinned to a single function instance for its lifetime; Fluid Compute lets one instance serve many concurrent connections. Active CPU pricing means you're billed while processing messages, not for idle open connections — the same limits and pricing as other Function invocations apply.\n\n### `ws` (no extra config)\n\nWebSockets work like any distributed WebSocket server — export an `http.Server` and use a library such as `ws`:\n\n```ts\n\u002F\u002F api\u002Fws.ts\nimport http from 'http'\nimport { WebSocketServer } from 'ws'\n\nconst server = http.createServer()\nconst wss = new WebSocketServer({ server })\n\nwss.on('connection', (ws) => {\n  ws.on('message', (data) => ws.send(data)) \u002F\u002F echo\n})\n\nexport default server\n```\n\n### Socket.IO\n\nHigher-level realtime libraries like Socket.IO work too. Configure the **client** to use the WebSocket transport directly — Socket.IO defaults to HTTP long-polling, which won't work:\n\n```ts\n\u002F\u002F api\u002Fsocket-io.ts\nimport http from 'http'\nimport { Server } from 'socket.io'\n\nconst server = http.createServer()\nconst io = new Server(server)\n\nio.on('connection', (socket) => {\n  socket.on('message', (data) => socket.send(data))\n})\n\nexport default server\n```\n\n```ts\n\u002F\u002F client.ts\nimport { io } from 'socket.io-client'\n\nconst socket = io('https:\u002F\u002Fyour-domain.com', {\n  \u002F\u002F Socket.IO appends \u002Fsocket.io, so the full path becomes \u002Fapi\u002Fsocket-io\u002Fsocket.io\n  path: '\u002Fapi\u002Fsocket-io\u002Fsocket.io',\n  transports: ['websocket'], \u002F\u002F required — Socket.IO defaults to HTTP long-polling\n})\n```\n\nExpress, Hono, and Nitro (including Nuxt, via native WebSocket support) serve WebSockets the same way — export the HTTP server. Python frameworks work too: FastAPI handles the upgrade natively, and `python-socketio` is protocol-compatible with the JS Socket.IO client.\n\n### Next.js\n\nNext.js doesn't expose an API for handling WebSocket upgrades. Use `experimental_upgradeWebSocket()` from `@vercel\u002Ffunctions` inside a route handler:\n\n```ts\n\u002F\u002F app\u002Fapi\u002Fws\u002Froute.ts\nimport { experimental_upgradeWebSocket, type WebSocketData } from '@vercel\u002Ffunctions'\n\nexport async function GET() {\n  return experimental_upgradeWebSocket((ws) => {\n    ws.on('message', (data: WebSocketData) => ws.send(data))\n  })\n}\n```\n\n### Reconnects and persistent state\n\n- **Connections close when the function reaches its max duration.** Clients must reconnect with backoff, then resubscribe to channels and reload any state they need.\n- **No instance affinity across connections.** A reconnect — or a new deployment — may land on a different instance, so never keep durable state, presence, rooms, or pub\u002Fsub coordination in memory. Use an external store such as [Redis from the Marketplace](https:\u002F\u002Fvercel.com\u002Fmarketplace\u002Fredis).\n\n```ts\n\u002F\u002F client.ts — reconnect with exponential backoff\nlet socket: WebSocket\nlet delay = 1000\n\nfunction connect() {\n  socket = new WebSocket('wss:\u002F\u002Fyour-domain.com\u002Fapi\u002Fws')\n  socket.addEventListener('open', () => { delay = 1000 })\n  socket.addEventListener('message', (e) => console.log(e.data))\n  socket.addEventListener('close', () => {\n    setTimeout(connect, delay)\n    delay = Math.min(delay * 2, 30000)\n  })\n}\n\nconnect()\n```\n\n## Cron Jobs\n\nSchedule function invocations via `vercel.json`:\n\n```json\n{\n  \"crons\": [\n    {\n      \"path\": \"\u002Fapi\u002Fdaily-report\",\n      \"schedule\": \"0 8 * * *\"\n    },\n    {\n      \"path\": \"\u002Fapi\u002Fcleanup\",\n      \"schedule\": \"0 *\u002F6 * * *\"\n    }\n  ]\n}\n```\n\nThe cron endpoint receives a normal HTTP request. Verify it's from Vercel:\n\n```ts\nexport async function GET(req: Request) {\n  const authHeader = req.headers.get('authorization')\n  if (authHeader !== `Bearer ${process.env.CRON_SECRET}`) {\n    return new Response('Unauthorized', { status: 401 })\n  }\n  \u002F\u002F Do scheduled work\n  return Response.json({ ok: true })\n}\n```\n\n## Configuration via vercel.json\n\n**Deprecation notice**: Support for the legacy `now.json` config file will be removed on **March 31, 2026**. Rename `now.json` to `vercel.json` (no content changes required).\n\n```json\n{\n  \"functions\": {\n    \"app\u002Fapi\u002Fheavy\u002F**\": {\n      \"maxDuration\": 300,\n      \"memory\": 1024\n    },\n    \"app\u002Fapi\u002Fedge\u002F**\": {\n      \"runtime\": \"edge\"\n    }\n  }\n}\n```\n\n## Timeout Limits\n\nAll plans now default to 300s execution time with Fluid Compute.\n\n| Plan | Default | Max |\n|------|---------|-----|\n| Hobby | 300s | 300s |\n| Pro | 300s | 800s |\n| Enterprise | 300s | 800s |\n\n## Common Pitfalls\n\n1. **Cold starts with DB connections**: Use connection pooling (e.g., Neon's `@neondatabase\u002Fserverless`)\n2. **Edge limitations**: No `fs`, no native modules, limited `crypto` — use Node.js runtime if needed\n3. **Timeout exceeded**: Use Fluid Compute for long-running tasks, or Workflow SDK for very long processes\n4. **Bundle size**: Functions support up to 5 GB package size on Fluid Compute (up from 250 MB); request bodies up to 100 MB (up from 4.5 MB)\n5. **Environment variables**: Available in all functions automatically; use `vercel env pull` for local dev\n\n## Function Runtime Diagnostics\n\n### Timeout Diagnostics\n\n```\n504 Gateway Timeout?\n├─ All plans default to 300s with Fluid Compute\n├─ Pro\u002FEnterprise: configurable up to 800s\n├─ Long-running task?\n│  ├─ Under 5 min → Use Fluid Compute with streaming\n│  ├─ Up to 15 min → Use Vercel Functions with `maxDuration` in vercel.json\n│  └─ Hours\u002Fdays → Use Workflow SDK (DurableAgent or workflow steps)\n└─ DB query slow? → Add connection pooling, check cold start, use Global Config\n```\n\n### 500 Error Diagnostics\n\n```\n500 Internal Server Error?\n├─ Check Vercel Runtime Logs (Dashboard → Deployments → Functions tab)\n├─ Missing env vars? → Compare `.env.local` against Vercel dashboard settings\n├─ Import error? → Verify package is in `dependencies`, not `devDependencies`\n└─ Uncaught exception? → Wrap handler in try\u002Fcatch, use `after()` for error reporting\n```\n\n### Invocation Failure Diagnostics\n\n```\n\"FUNCTION_INVOCATION_FAILED\"?\n├─ Memory exceeded? → Increase `memory` in vercel.json (up to 3008 MB on Pro)\n├─ Crashed during init? → Check top-level await or heavy imports at module scope\n└─ Edge Function crash? → Check for Node.js APIs not available in Edge runtime\n```\n\n### Cold Start Diagnostics\n\n```\nCold start latency > 1s?\n├─ Using Node.js runtime? → Consider Edge Functions for latency-sensitive routes\n├─ Large function bundle? → Audit imports, use dynamic imports, tree-shake\n├─ DB connection in cold start? → Use connection pooling (Neon serverless driver)\n└─ Enable Fluid Compute to reuse warm instances across requests\n```\n\n### Edge Function Timeout Diagnostics\n\n```\n\"EDGE_FUNCTION_INVOCATION_TIMEOUT\"?\n├─ Edge Functions have 25s hard limit (not configurable)\n├─ Move heavy computation to Node.js Serverless Functions\n└─ Use streaming to start response early, process in background with `waitUntil`\n```\n\n## Official Documentation\n\n- [Vercel Functions](https:\u002F\u002Fvercel.com\u002Fdocs\u002Ffunctions)\n- [Serverless Functions](https:\u002F\u002Fvercel.com\u002Fdocs\u002Ffunctions)\n- [Edge Functions](https:\u002F\u002Fvercel.com\u002Fdocs\u002Ffunctions)\n- [Fluid Compute](https:\u002F\u002Fvercel.com\u002Fdocs\u002Ffluid-compute)\n- [Streaming](https:\u002F\u002Fvercel.com\u002Fdocs\u002Ffunctions\u002Fstreaming)\n- [WebSockets](https:\u002F\u002Fvercel.com\u002Fdocs\u002Ffunctions\u002Fwebsockets)\n- [Cron Jobs](https:\u002F\u002Fvercel.com\u002Fdocs\u002Fcron-jobs)\n- [GitHub: Vercel](https:\u002F\u002Fgithub.com\u002Fvercel\u002Fvercel)\n","# Vercel Functions\n\nYou are an expert in Vercel Functions — the compute layer of the Vercel platform.\n\n## Function Types\n\n### Serverless Functions (Node.js)\n- Full Node.js runtime, all npm packages available\n- Default for Next.js API routes, Server Actions, Server Components\n- Cold starts: 800ms–2.5s (with DB connections)\n- Max duration: 10s (Hobby), 300s (Pro default), 800s (Fluid Compute Pro\u002FEnterprise)\n\n```ts\n\u002F\u002F app\u002Fapi\u002Fhello\u002Froute.ts\nexport async function GET() {\n  return Response.json({ message: 'Hello from Node.js' })\n}\n```\n\n### Edge Functions (V8 Isolates)\n- Lightweight V8 runtime, Web Standard APIs only\n- Ultra-low cold starts (\u003C1ms globally)\n- Limited API surface (no full Node.js)\n- Best for: auth checks, redirects, A\u002FB testing, simple transformations\n\n```ts\n\u002F\u002F app\u002Fapi\u002Fhello\u002Froute.ts\nexport const runtime = 'edge'\n\nexport async function GET() {\n  return new Response('Hello from the Edge')\n}\n```\n\n### Bun Runtime (Public Beta)\n\nAdd `\"bunVersion\": \"1.x\"` to `vercel.json` to run Node.js functions on Bun instead. ~28% lower latency for CPU-bound workloads. Supports Next.js, Express, Hono, Nitro.\n\n### Rust Runtime (Public Beta)\n\nRust functions run on Fluid Compute with HTTP streaming and Active CPU pricing. Built on the community Rust runtime. Supports environment variables up to 64 KB.\n\n### Node.js 24 LTS\n\nNode.js 24 LTS is now GA on Vercel for both builds and functions. Features V8 13.6, global `URLPattern`, Undici v7 for faster `fetch()`, and npm v11.\n\n### Choosing Runtime\n\n| Need | Runtime | Why |\n|------|---------|-----|\n| Full Node.js APIs, npm packages | `nodejs` | Full compatibility |\n| Lower latency, CPU-bound work | `nodejs` + Bun | ~28% latency reduction |\n| Ultra-low latency, simple logic | `edge` | \u003C1ms cold start, global |\n| Database connections, heavy deps | `nodejs` | Edge lacks full Node.js |\n| Auth\u002Fredirect at the edge | `edge` | Fastest response |\n| AI streaming | Either | Both support streaming |\n| Systems-level performance | `rust` (beta) | Native speed, Fluid Compute |\n\n## Fluid Compute\n\nFluid Compute is the unified execution model for all Vercel Functions (both Node.js and Edge).\n\nKey benefits:\n- **Optimized concurrency**: Multiple invocations on a single instance — up to 85% cost reduction for high-concurrency workloads\n- **Extended durations**: Default 300s for all plans; up to 800s on Pro\u002FEnterprise\n- **Active CPU pricing**: Charges only while CPU is actively working, not during idle\u002Fawait time. Enabled by default for all plans. Memory-only periods billed at a significantly lower rate.\n- **Background processing**: `waitUntil` \u002F `after` for post-response tasks\n- **Dynamic scaling**: Automatic during traffic spikes\n- **Bytecode caching**: Reduces cold starts via Rust-based runtime with pre-compiled function code\n- **Multi-region failover**: Default for Enterprise when Fluid is activated\n\n### Instance Sizes\n\n| Size | CPU | Memory |\n|------|-----|--------|\n| Standard (default) | 1 vCPU | 2 GB |\n| Performance | 2 vCPU | 4 GB |\n\nHobby projects use Standard CPU. The Basic CPU instance has been removed.\n\n### Background Processing with `waitUntil`\n\n```ts\n\u002F\u002F Continue work after sending response\nimport { waitUntil } from '@vercel\u002Ffunctions'\n\nexport async function POST(req: Request) {\n  const data = await req.json()\n\n  \u002F\u002F Send response immediately\n  const response = Response.json({ received: true })\n\n  \u002F\u002F Continue processing in background\n  waitUntil(async () => {\n    await processAnalytics(data)\n    await sendNotification(data)\n  })\n\n  return response\n}\n```\n\n### Next.js `after` (equivalent)\n\n```ts\nimport { after } from 'next\u002Fserver'\n\nexport async function POST(req: Request) {\n  const data = await req.json()\n\n  after(async () => {\n    await logToAnalytics(data)\n  })\n\n  return Response.json({ ok: true })\n}\n```\n\n## Streaming\n\nZero-config streaming on **both runtimes**, including Server-Sent Events (SSE). Essential for AI applications.\n\n> **You do NOT need `runtime = 'edge'` for streaming or SSE.** Streaming responses (`ReadableStream`, `text\u002Fevent-stream`) work on the default Node.js runtime — this is a common misconception. Stay on Node.js (Fluid Compute) so you keep full Node.js APIs, npm packages, and longer durations; Edge offers no streaming advantage here.\n\n```ts\nexport async function POST(req: Request) {\n  const encoder = new TextEncoder()\n  const stream = new ReadableStream({\n    async start(controller) {\n      for (const chunk of data) {\n        controller.enqueue(encoder.encode(chunk))\n        await new Promise(r => setTimeout(r, 100))\n      }\n      controller.close()\n    },\n  })\n\n  return new Response(stream, {\n    headers: { 'Content-Type': 'text\u002Fevent-stream' },\n  })\n}\n```\n\nFor AI streaming, use the AI SDK's `toUIMessageStreamResponse()` (for chat UIs with `useChat`) which handles SSE formatting automatically.\n\n## WebSockets\n\nVercel Functions can hold open bidirectional WebSocket connections — use them for realtime features like interactive AI streaming, chat, and collaborative apps. There is **no separate WebSocket-server product and no third-party service (Pusher, Ably, etc.) required** — it runs on Vercel Functions directly. Requires **Fluid Compute**, which is the default for new projects.\n\n**How it works**: a WebSocket starts as an HTTP `GET` with an `Upgrade` header, so it passes through the same Routing Middleware, rewrites, Firewall rules, and rate limits as any other request. After the upgrade, the connection is pinned to a single function instance for its lifetime; Fluid Compute lets one instance serve many concurrent connections. Active CPU pricing means you're billed while processing messages, not for idle open connections — the same limits and pricing as other Function invocations apply.\n\n### `ws` (no extra config)\n\nWebSockets work like any distributed WebSocket server — export an `http.Server` and use a library such as `ws`:\n\n```ts\n\u002F\u002F api\u002Fws.ts\nimport http from 'http'\nimport { WebSocketServer } from 'ws'\n\nconst server = http.createServer()\nconst wss = new WebSocketServer({ server })\n\nwss.on('connection', (ws) => {\n  ws.on('message', (data) => ws.send(data)) \u002F\u002F echo\n})\n\nexport default server\n```\n\n### Socket.IO\n\nHigher-level realtime libraries like Socket.IO work too. Configure the **client** to use the WebSocket transport directly — Socket.IO defaults to HTTP long-polling, which won't work:\n\n```ts\n\u002F\u002F api\u002Fsocket-io.ts\nimport http from 'http'\nimport { Server } from 'socket.io'\n\nconst server = http.createServer()\nconst io = new Server(server)\n\nio.on('connection', (socket) => {\n  socket.on('message', (data) => socket.send(data))\n})\n\nexport default server\n```\n\n```ts\n\u002F\u002F client.ts\nimport { io } from 'socket.io-client'\n\nconst socket = io('https:\u002F\u002Fyour-domain.com', {\n  \u002F\u002F Socket.IO appends \u002Fsocket.io, so the full path becomes \u002Fapi\u002Fsocket-io\u002Fsocket.io\n  path: '\u002Fapi\u002Fsocket-io\u002Fsocket.io',\n  transports: ['websocket'], \u002F\u002F required — Socket.IO defaults to HTTP long-polling\n})\n```\n\nExpress, Hono, and Nitro (including Nuxt, via native WebSocket support) serve WebSockets the same way — export the HTTP server. Python frameworks work too: FastAPI handles the upgrade natively, and `python-socketio` is protocol-compatible with the JS Socket.IO client.\n\n### Next.js\n\nNext.js doesn't expose an API for handling WebSocket upgrades. Use `experimental_upgradeWebSocket()` from `@vercel\u002Ffunctions` inside a route handler:\n\n```ts\n\u002F\u002F app\u002Fapi\u002Fws\u002Froute.ts\nimport { experimental_upgradeWebSocket, type WebSocketData } from '@vercel\u002Ffunctions'\n\nexport async function GET() {\n  return experimental_upgradeWebSocket((ws) => {\n    ws.on('message', (data: WebSocketData) => ws.send(data))\n  })\n}\n```\n\n### Reconnects and persistent state\n\n- **Connections close when the function reaches its max duration.** Clients must reconnect with backoff, then resubscribe to channels and reload any state they need.\n- **No instance affinity across connections.** A reconnect — or a new deployment — may land on a different instance, so never keep durable state, presence, rooms, or pub\u002Fsub coordination in memory. Use an external store such as [Redis from the Marketplace](https:\u002F\u002Fvercel.com\u002Fmarketplace\u002Fredis).\n\n```ts\n\u002F\u002F client.ts — reconnect with exponential backoff\nlet socket: WebSocket\nlet delay = 1000\n\nfunction connect() {\n  socket = new WebSocket('wss:\u002F\u002Fyour-domain.com\u002Fapi\u002Fws')\n  socket.addEventListener('open', () => { delay = 1000 })\n  socket.addEventListener('message', (e) => console.log(e.data))\n  socket.addEventListener('close', () => {\n    setTimeout(connect, delay)\n    delay = Math.min(delay * 2, 30000)\n  })\n}\n\nconnect()\n```\n\n## Cron Jobs\n\nSchedule function invocations via `vercel.json`:\n\n```json\n{\n  \"crons\": [\n    {\n      \"path\": \"\u002Fapi\u002Fdaily-report\",\n      \"schedule\": \"0 8 * * *\"\n    },\n    {\n      \"path\": \"\u002Fapi\u002Fcleanup\",\n      \"schedule\": \"0 *\u002F6 * * *\"\n    }\n  ]\n}\n```\n\nThe cron endpoint receives a normal HTTP request. Verify it's from Vercel:\n\n```ts\nexport async function GET(req: Request) {\n  const authHeader = req.headers.get('authorization')\n  if (authHeader !== `Bearer ${process.env.CRON_SECRET}`) {\n    return new Response('Unauthorized', { status: 401 })\n  }\n  \u002F\u002F Do scheduled work\n  return Response.json({ ok: true })\n}\n```\n\n## Configuration via vercel.json\n\n**Deprecation notice**: Support for the legacy `now.json` config file will be removed on **March 31, 2026**. Rename `now.json` to `vercel.json` (no content changes required).\n\n```json\n{\n  \"functions\": {\n    \"app\u002Fapi\u002Fheavy\u002F**\": {\n      \"maxDuration\": 300,\n      \"memory\": 1024\n    },\n    \"app\u002Fapi\u002Fedge\u002F**\": {\n      \"runtime\": \"edge\"\n    }\n  }\n}\n```\n\n## Timeout Limits\n\nAll plans now default to 300s execution time with Fluid Compute.\n\n| Plan | Default | Max |\n|------|---------|-----|\n| Hobby | 300s | 300s |\n| Pro | 300s | 800s |\n| Enterprise | 300s | 800s |\n\n## Common Pitfalls\n\n1. **Cold starts with DB connections**: Use connection pooling (e.g., Neon's `@neondatabase\u002Fserverless`)\n2. **Edge limitations**: No `fs`, no native modules, limited `crypto` — use Node.js runtime if needed\n3. **Timeout exceeded**: Use Fluid Compute for long-running tasks, or Workflow SDK for very long processes\n4. **Bundle size**: Functions support up to 5 GB package size on Fluid Compute (up from 250 MB); request bodies up to 100 MB (up from 4.5 MB)\n5. **Environment variables**: Available in all functions automatically; use `vercel env pull` for local dev\n\n## Function Runtime Diagnostics\n\n### Timeout Diagnostics\n\n```\n504 Gateway Timeout?\n├─ All plans default to 300s with Fluid Compute\n├─ Pro\u002FEnterprise: configurable up to 800s\n├─ Long-running task?\n│  ├─ Under 5 min → Use Fluid Compute with streaming\n│  ├─ Up to 15 min → Use Vercel Functions with `maxDuration` in vercel.json\n│  └─ Hours\u002Fdays → Use Workflow SDK (DurableAgent or workflow steps)\n└─ DB query slow? → Add connection pooling, check cold start, use Global Config\n```\n\n### 500 Error Diagnostics\n\n```\n500 Internal Server Error?\n├─ Check Vercel Runtime Logs (Dashboard → Deployments → Functions tab)\n├─ Missing env vars? → Compare `.env.local` against Vercel dashboard settings\n├─ Import error? → Verify package is in `dependencies`, not `devDependencies`\n└─ Uncaught exception? → Wrap handler in try\u002Fcatch, use `after()` for error reporting\n```\n\n### Invocation Failure Diagnostics\n\n```\n\"FUNCTION_INVOCATION_FAILED\"?\n├─ Memory exceeded? → Increase `memory` in vercel.json (up to 3008 MB on Pro)\n├─ Crashed during init? → Check top-level await or heavy imports at module scope\n└─ Edge Function crash? → Check for Node.js APIs not available in Edge runtime\n```\n\n### Cold Start Diagnostics\n\n```\nCold start latency > 1s?\n├─ Using Node.js runtime? → Consider Edge Functions for latency-sensitive routes\n├─ Large function bundle? → Audit imports, use dynamic imports, tree-shake\n├─ DB connection in cold start? → Use connection pooling (Neon serverless driver)\n└─ Enable Fluid Compute to reuse warm instances across requests\n```\n\n### Edge Function Timeout Diagnostics\n\n```\n\"EDGE_FUNCTION_INVOCATION_TIMEOUT\"?\n├─ Edge Functions have 25s hard limit (not configurable)\n├─ Move heavy computation to Node.js Serverless Functions\n└─ Use streaming to start response early, process in background with `waitUntil`\n```\n\n## Official Documentation\n\n- [Vercel Functions](https:\u002F\u002Fvercel.com\u002Fdocs\u002Ffunctions)\n- [Serverless Functions](https:\u002F\u002Fvercel.com\u002Fdocs\u002Ffunctions)\n- [Edge Functions](https:\u002F\u002Fvercel.com\u002Fdocs\u002Ffunctions)\n- [Fluid Compute](https:\u002F\u002Fvercel.com\u002Fdocs\u002Ffluid-compute)\n- [Streaming](https:\u002F\u002Fvercel.com\u002Fdocs\u002Ffunctions\u002Fstreaming)\n- [WebSockets](https:\u002F\u002Fvercel.com\u002Fdocs\u002Ffunctions\u002Fwebsockets)\n- [Cron Jobs](https:\u002F\u002Fvercel.com\u002Fdocs\u002Fcron-jobs)\n- [GitHub: Vercel](https:\u002F\u002Fgithub.com\u002Fvercel\u002Fvercel)\n",{"name":5,"chainTo":49,"metadata":85,"validate":127,"retrieval":167,"description":7},[50,54,58,62,65,68,72,76,81],{"message":51,"pattern":52,"targetSkill":53},"Direct AI provider SDK in route handler — loading AI SDK guidance for unified streaming and tool support.","from\\s+['\\\"](openai|@anthropic-ai\u002Fsdk|anthropic)['\"]|new\\s+(OpenAI|Anthropic)\\(","ai-sdk",{"message":55,"pattern":56,"targetSkill":57},"Long-running or polling logic in serverless handler — loading Workflow SDK for durable execution.","setTimeout\\s*\\(|setInterval\\s*\\(|await\\s+new\\s+Promise\\s*\\([^)]*setTimeout","workflow",{"message":59,"pattern":60,"targetSkill":61},"Local filesystem write in serverless function — loading Vercel Storage guidance for platform-native persistence.","writeFile(Sync)?\\(|createWriteStream\\(|from\\s+['\\\"](multer|formidable)['\"]|fs\\.writeFile","vercel-storage",{"message":63,"pattern":64,"targetSkill":61},"@vercel\u002Fpostgres and @vercel\u002Fkv are sunset — loading Vercel Storage guidance for Neon and Upstash migration.","from\\s+['\"\"]@vercel\u002F(postgres|kv)['\"\"]",{"message":66,"pattern":67,"targetSkill":53},"Deprecated AI SDK v5 API detected — loading AI SDK v6 guidance for migration.","generateObject\\s*\\(|streamObject\\s*\\(|toDataStreamResponse|maxSteps\\b|CoreMessage\\b",{"message":69,"pattern":70,"targetSkill":57,"skipIfFileContains":71},"Polling loop in serverless function detected — loading Workflow SDK for durable, crash-safe execution with pause\u002Fresume.","while\\s*\\(\\s*true\\s*\\)\\s*\\{|for\\s*\\(\\s*;\\s*;\\s*\\)\\s*\\{|setInterval\\s*\\(\\s*async","use workflow|use step|from\\s+['\"]workflow['\"]",{"message":73,"pattern":74,"targetSkill":5,"skipIfFileContains":75},"Express.js detected — loading Vercel Functions guidance for Web Request\u002FResponse API route handlers that replace Express middleware and routing.","from\\s+['\"]express['\"]|require\\s*\\(\\s*['\"]express['\"]","export\\s+(async\\s+)?function\\s+(GET|POST|PUT|PATCH|DELETE)",{"message":77,"pattern":78,"targetSkill":79,"skipIfFileContains":80},"In-process memory cache in serverless function — loading Runtime Cache guidance for region-aware caching that persists across invocations.","from\\s+['\"\"](lru-cache|node-cache|memory-cache)['\"\"]|new\\s+(LRUCache|NodeCache|Map)\\(\\s*\\).*cache","runtime-cache","getCache|from\\s+['\"\"]\\@vercel\u002Ffunctions['\"\"]",{"message":82,"pattern":83,"targetSkill":57,"skipIfFileContains":84},"Manual retry logic in serverless handler — loading Workflow SDK guidance for automatic retries with durable execution.","maxRetries\\s*[=:]|retryCount\\s*[=:]|retry\\s*\\(\\s*|for\\s*\\([^)]*retry|while\\s*\\([^)]*retry","use workflow|use step|@vercel\u002Fworkflow|from\\s+['\"\"](workflow)['\"\"]",{"docs":86,"sitemap":90,"priority":91,"bashPatterns":92,"pathPatterns":95,"promptSignals":107,"importPatterns":124},[87,88,89],"https:\u002F\u002Fvercel.com\u002Fdocs\u002Ffunctions","https:\u002F\u002Fvercel.com\u002Fdocs\u002Ffunctions\u002Fruntimes","https:\u002F\u002Fvercel.com\u002Fdocs\u002Ffunctions\u002Fwebsockets","https:\u002F\u002Fvercel.com\u002Fsitemap.xml",8,[93,94],"\\bvercel\\s+dev\\b","\\bvercel\\s+logs\\b",[96,97,98,99,100,101,102,103,104,105,106],"api\u002F**\u002F*.*","pages\u002Fapi\u002F**","src\u002Fpages\u002Fapi\u002F**","app\u002F**\u002Froute.*","src\u002Fapp\u002F**\u002Froute.*","apps\u002F*\u002Fapi\u002F**\u002F*.*","apps\u002F*\u002Fapp\u002F**\u002Froute.*","apps\u002F*\u002Fsrc\u002Fapp\u002F**\u002Froute.*","apps\u002F*\u002Fpages\u002Fapi\u002F**","vercel.json","apps\u002F*\u002Fvercel.json",{"allOf":108,"anyOf":109,"noneOf":115,"phrases":116,"minScore":123},[],[110,111,112,113,114],"realtime","bidirectional","ws server","polling","server-sent events",[],[117,118,119,120,121,122],"websocket","websockets","web socket","socket.io","long polling","long-polling",6,[125,120,126],"ws","socket.io-client",[128,133,136,142,146,151,156,159,162],{"message":129,"pattern":130,"severity":131,"skipIfFileContains":132},"Use named exports (GET, POST, PUT, DELETE) instead of default export for route handlers","export\\s+default\\s+function","error","(?:^|\\n)\\s*['\"]use\\s+client['\"]|export\\s+const\\s+(?:metadata|dynamic|revalidate|fetchCache|runtime)\\b|export\\s+default\\s+(?:async\\s+)?function\\s+\\w*(?:Page|Layout|Loading|Error|NotFound|Sitemap|Template|Default|sitemap|robots|opengraph|manifest)\\b|\u003C[A-Z][A-Za-z0-9]*|\\{\\s*children\\s*[,}:]|MetadataRoute\\.|from\\s+['\"]next\u002F(?:font|image|link|navigation|headers|cookies)['\"]",{"message":134,"pattern":135,"severity":131},"NextApiRequest\u002FNextApiResponse are Pages Router types — use Web API Request\u002FResponse","NextApiRequest|NextApiResponse",{"message":137,"pattern":138,"severity":139,"upgradeWhy":140,"upgradeToSkill":53,"skipIfFileContains":141},"Direct AI provider SDK detected in route handler. Use the Vercel AI SDK for streaming, tools, and provider abstraction.","from\\s+['\"](openai|@anthropic-ai\u002Fsdk|anthropic)['\"]|new\\s+(OpenAI|Anthropic)\\(","recommended","Replace vendor-locked provider SDKs with @ai-sdk\u002Fopenai or @ai-sdk\u002Fanthropic for unified streaming and tool support.","@ai-sdk\u002F|from\\s+['\"](ai)['\"]|import.*from\\s+['\"](ai)['\"]|streamText|generateText",{"message":143,"pattern":56,"severity":139,"upgradeWhy":144,"upgradeToSkill":57,"skipIfFileContains":145},"Long-running or polling logic detected in a serverless handler. Functions have execution time limits.","Move delayed\u002Fpolling logic to Vercel Workflow for durable execution with pause, resume, retries, and crash safety.","use workflow|use step|@vercel\u002Fworkflow",{"message":147,"pattern":148,"severity":131,"upgradeWhy":149,"upgradeToSkill":61,"skipIfFileContains":150},"Local filesystem write detected. Serverless functions have ephemeral, read-only filesystems.","writeFile(Sync)?\\(|createWriteStream\\(|from\\s+['\"](multer|formidable)['\"]|fs\\.writeFile","Replace local filesystem writes with Vercel Blob, Neon, or Upstash for persistent, platform-native storage.","@vercel\u002Fblob|@upstash\u002F|@neondatabase\u002F",{"message":152,"pattern":153,"severity":154,"skipIfFileContains":155},"Route handler has no observability instrumentation. Add logging and error tracking for production debugging.","export\\s+(async\\s+)?function\\s+(GET|POST|PUT|PATCH|DELETE)\\b","warn","console\\.error|logger\\.|captureException|Sentry|@vercel\u002Fotel|withTracing",{"message":157,"pattern":78,"severity":139,"upgradeWhy":158,"upgradeToSkill":79,"skipIfFileContains":80},"In-process memory cache detected in serverless function. Process memory is not shared across invocations.","Replace in-process caches with Vercel Runtime Cache (getCache from @vercel\u002Ffunctions) for region-aware caching that persists across invocations.",{"message":160,"pattern":83,"severity":139,"upgradeWhy":161,"upgradeToSkill":57,"skipIfFileContains":84},"Manual retry logic detected. Use Vercel Workflow SDK for automatic retries with durable execution.","Replace manual retry loops with Workflow SDK steps that provide automatic retries, crash safety, and observability.",{"message":163,"pattern":164,"severity":139,"upgradeWhy":165,"upgradeToSkill":5,"skipIfFileContains":166},"Express.js detected in a Vercel project. Vercel Functions use the Web Request\u002FResponse API — Express middleware, req\u002Fres, and app.listen() do not work in serverless.","from\\s+['\"](express)['\"\"]|require\\s*\\(\\s*['\"](express)['\"\"\\)]","Replace Express with Next.js route handlers (export async function GET\u002FPOST) or Vercel Functions using the Web Request\u002FResponse API.","export\\s+(async\\s+)?function\\s+(GET|POST|PUT|PATCH|DELETE)|from\\s+['\"\"](next\u002Fserver|@vercel\u002Ffunctions)['\"\"]",{"aliases":168,"intents":173,"entities":179},[169,170,171,172,118,120],"serverless functions","api routes","edge functions","lambda",[174,175,176,177,178],"create serverless function","configure function runtime","optimize cold starts","add api route","serve a websocket connection",[180,181,182,183,184,185],"Serverless Functions","Edge Functions","Fluid Compute","streaming","WebSockets","Cron Jobs","main","e6ee720f466a8344a52abd87679191fadde3b63f",".agents\u002Fskills\u002Fvercel-functions","https:\u002F\u002Fgithub.com\u002Fpatinaproject\u002Fskills","https:\u002F\u002Fgithub.com\u002Fpatinaproject","https:\u002F\u002Fwww.patinaproject.com","The best way to pick your next pair of boots or shoes.","2026-11-12 00:44:02",{"source":8,"skillName":5,"commands":195,"prompt":205,"zipAvailable":206},[196,199,202],{"tool":197,"command":198},"npx","npx skills add patinaproject\u002Fskills --skill vercel-functions",{"tool":200,"command":201},"bunx","bunx skills add patinaproject\u002Fskills --skill vercel-functions",{"tool":203,"command":204},"pnpm","pnpm dlx skills add patinaproject\u002Fskills --skill vercel-functions","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002Fpatinaproject\u002Fskills\u002Fblob\u002Fmain\u002F.agents\u002Fskills\u002Fvercel-functions\u002FSKILL.md",true,[],[209,217,246,258,281,303],{"skillNo":210,"name":211,"nameZh":6,"description":212,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":213,"categories":214,"keywords":215,"publishedAt":216},"01M72KDQJR99954NE224VB3KZ2","code-review","Review the changes since a fixed point (commit, branch, tag, or merge-base) along five axes: Standards (does the code follow this repo's documented coding standards?), Spec (does the code match what the originating issue\u002Fspec asked for?), Evidence (does each claim in the pull request have evidence that shows it?), Bugs (does the changed code have logic errors, unhandled states, races, or regressions?), and Security (does the change open injection, auth, secret, input, or CI workflow holes?). Runs the reviews in parallel sub-agents, tags every finding Important, Nit, or Pre-existing, and reports them side by side with what blocks merge. Given an earlier reviewed head and its findings, it reviews only the newer commits, rechecks the earlier findings, and never repeats one. Use when the user wants to review a branch, a PR, work-in-progress changes, or asks to \"review since X\".","https:\u002F\u002Fgithub.com\u002Fpatinaproject\u002Fskills\u002Fblob\u002Fmain\u002Fplugins\u002Fcode\u002Fskills\u002Fcode-review\u002FSKILL.md",[],[],"2026-11-10 22:39:42",{"skillNo":218,"name":219,"nameZh":6,"description":220,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":221,"categories":222,"keywords":231,"publishedAt":44},"01M71ESEDVHD9EXN6787XHP7HD","writing-for-pstack","Write or tighten an operator prompt for a patina-mode run. Use when the operator asks to write, revise, or review a prompt that will be passed to patina-mode.","https:\u002F\u002Fgithub.com\u002Fpatinaproject\u002Fskills\u002Fblob\u002Fmain\u002Fplugins\u002Fwork\u002Fskills\u002Fwriting-for-pstack\u002FSKILL.md",[223,226],{"categoryNo":224,"categoryName":225,"taxonomyType":21,"taxonomyTypeDesc":22},"01JBSEEDCAT000000000000018","写作与文案",{"categoryNo":227,"categoryName":228,"taxonomyType":229,"taxonomyTypeDesc":230},"01JBSEEDCAT000000000000036","内容创作者","PROFESSION","适用职业",[232,233,234,235,236,237,238,239,240,241,242,243,244,245],"for","pstack","writing","writing for pstack","review","run","mode","write","operator","use","tighten","prompt","when","revise",{"skillNo":247,"name":248,"nameZh":6,"description":249,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":250,"categories":251,"keywords":254,"publishedAt":44},"01M71ESCJ0SSJFFENF8HYDKBTJ","writing-for-agents","Writing documents for agents. Use when creating or editing skills, or modifying AGENTS.md or CLAUDE.md.","https:\u002F\u002Fgithub.com\u002Fpatinaproject\u002Fskills\u002Fblob\u002Fmain\u002Fplugins\u002Fwork\u002Fskills\u002Fwriting-for-agents\u002FSKILL.md",[252,253],{"categoryNo":224,"categoryName":225,"taxonomyType":21,"taxonomyTypeDesc":22},{"categoryNo":227,"categoryName":228,"taxonomyType":229,"taxonomyTypeDesc":230},[255,232,234,256,241,257,244],"writing for agents","editing","documents",{"skillNo":259,"name":260,"nameZh":6,"description":261,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":262,"categories":263,"keywords":264,"publishedAt":44},"01M71ESA1NN9WVMD2HA5Z1RRDY","wizard","Generate an interactive bash wizard that walks a human through steps only they can perform. Use when provisioning infrastructure, setting up credentials or CI secrets, walking an unfamiliar third-party dashboard, or running a one-off migration or cutover. Don't invoke this for steps the agent can perform itself.","https:\u002F\u002Fgithub.com\u002Fpatinaproject\u002Fskills\u002Fblob\u002Fmain\u002Fplugins\u002Fwork\u002Fskills\u002Fwizard\u002FSKILL.md",[],[260,265,266,267,268,269,244,270,271,272,273,274,241,275,276,277,232,278,279,280],"interactive","can","credentials","one","Bash","invoke","dashboard","generate","human","secrets","provisioning infrastructure","ci","up","setting","running","only",{"skillNo":282,"name":283,"nameZh":6,"description":284,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":285,"categories":286,"keywords":287,"publishedAt":44},"01M71ES8FAN567N3JEPG8W6AS1","wayfinder","Plan a huge chunk of work (more than one agent session can hold) as a shared map of decision tickets on your issue tracker, and resolve them one at a time until the way to the destination is clear.","https:\u002F\u002Fgithub.com\u002Fpatinaproject\u002Fskills\u002Fblob\u002Fmain\u002Fplugins\u002Fwork\u002Fskills\u002Fwayfinder\u002FSKILL.md",[],[283,288,289,290,291,36,292,293,43,294,295,296,297,298,299,300,301,266,302,268],"more","true","decision","session","chunk","as","map","tickets","destination","at","tracker","plan","work","agent session","one at a time",{"skillNo":304,"name":305,"nameZh":6,"description":306,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":307,"categories":308,"keywords":309,"publishedAt":44},"01M71ES6PWJPKBW8R24YFH4PY6","wait-what","Stop. That last message did not land: re-pitch it.","https:\u002F\u002Fgithub.com\u002Fpatinaproject\u002Fskills\u002Fblob\u002Fmain\u002Fplugins\u002Fwork\u002Fskills\u002Fwait-what\u002FSKILL.md",[],[310,311,312,313,314,315,316,317,289,318],"wait","wait what","stop","it","land","re","pitch","message","last"]