[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M6K1XH0K0KC0CB51QFWYQ3NM":3,"skill-same:01M6K1XH0K0KC0CB51QFWYQ3NM":181},{"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":18,"publishedAt":39,"linkOnly":40,"markdownContent":41,"markdownBody":42,"frontMatter":43,"refName":158,"commitSha":159,"skillDirectory":160,"forksCount":161,"repositoryHtmlUrl":162,"repositoryHomepageUrl":6,"ownerHtmlUrl":163,"ownerBlogUrl":164,"ownerDescription":165,"updatedAt":166,"install":167,"resources":180},"01M6K1XH0K0KC0CB51QFWYQ3NM","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.","NagyVikt\u002Fcodex-plugins","NagyVikt","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F137165288?v=4","01M6K0SJ3R2DAZRJKJJS10VN87","Viktor Nagy","01M6K0SJ9HXN0GBD91QDQ9WNVV",2,"MIT","https:\u002F\u002Fgithub.com\u002FNagyVikt\u002Fcodex-plugins\u002Fblob\u002Fmain\u002Fplugins\u002Fvercel\u002Fskills\u002Fvercel-functions\u002FSKILL.md",[],[19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38],"vercel functions","vercel","functions","local","move","retries","cold","apps","app","neon","express","project","shared","streaming","time","expert","vercel ai sdk","router","loop","logs","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  sitemap: \"https:\u002F\u002Fvercel.com\u002Fsitemap\u002Fdocs.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'\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  -\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    upgradeToSkill: observability\n    upgradeWhy: 'Add structured logging, error tracking, and OTel instrumentation to route handlers.'\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 DevKit for automatic retries with durable execution.'\n    severity: recommended\n    upgradeToSkill: workflow\n    upgradeWhy: 'Replace manual retry loops with Workflow DevKit 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  intents:\n    - create serverless function\n    - configure function runtime\n    - optimize cold starts\n    - add api route\n  entities:\n    - Serverless Functions\n    - Edge Functions\n    - Fluid Compute\n    - streaming\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 DevKit 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 DevKit 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 DevKit 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 for both runtimes. Essential for AI applications.\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## 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 DevKit for very long processes\n4. **Bundle size**: Python runtime supports up to 500MB; Node.js has smaller limits\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 DevKit (DurableAgent or workflow steps)\n└─ DB query slow? → Add connection pooling, check cold start, use Edge 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- [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 for both runtimes. Essential for AI applications.\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## 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 DevKit for very long processes\n4. **Bundle size**: Python runtime supports up to 500MB; Node.js has smaller limits\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 DevKit (DurableAgent or workflow steps)\n└─ DB query slow? → Add connection pooling, check cold start, use Edge 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- [Cron Jobs](https:\u002F\u002Fvercel.com\u002Fdocs\u002Fcron-jobs)\n- [GitHub: Vercel](https:\u002F\u002Fgithub.com\u002Fvercel\u002Fvercel)\n",{"name":5,"chainTo":44,"metadata":80,"validate":101,"retrieval":142,"description":7},[45,49,53,57,60,63,67,71,76],{"message":46,"pattern":47,"targetSkill":48},"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":50,"pattern":51,"targetSkill":52},"Long-running or polling logic in serverless handler — loading Workflow DevKit for durable execution.","setTimeout\\s*\\(|setInterval\\s*\\(|await\\s+new\\s+Promise\\s*\\([^)]*setTimeout","workflow",{"message":54,"pattern":55,"targetSkill":56},"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":58,"pattern":59,"targetSkill":56},"@vercel\u002Fpostgres and @vercel\u002Fkv are sunset — loading Vercel Storage guidance for Neon and Upstash migration.","from\\s+['\"\"]@vercel\u002F(postgres|kv)['\"\"]",{"message":61,"pattern":62,"targetSkill":48},"Deprecated AI SDK v5 API detected — loading AI SDK v6 guidance for migration.","generateObject\\s*\\(|streamObject\\s*\\(|toDataStreamResponse|maxSteps\\b|CoreMessage\\b",{"message":64,"pattern":65,"targetSkill":52,"skipIfFileContains":66},"Polling loop in serverless function detected — loading Workflow DevKit 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":68,"pattern":69,"targetSkill":5,"skipIfFileContains":70},"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":72,"pattern":73,"targetSkill":74,"skipIfFileContains":75},"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":77,"pattern":78,"targetSkill":52,"skipIfFileContains":79},"Manual retry logic in serverless handler — loading Workflow DevKit 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":81,"sitemap":84,"priority":85,"bashPatterns":86,"pathPatterns":89},[82,83],"https:\u002F\u002Fvercel.com\u002Fdocs\u002Ffunctions","https:\u002F\u002Fvercel.com\u002Fdocs\u002Ffunctions\u002Fruntimes","https:\u002F\u002Fvercel.com\u002Fsitemap\u002Fdocs.xml",8,[87,88],"\\bvercel\\s+dev\\b","\\bvercel\\s+logs\\b",[90,91,92,93,94,95,96,97,98,99,100],"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",[102,106,109,115,119,124,131,134,137],{"message":103,"pattern":104,"severity":105},"Use named exports (GET, POST, PUT, DELETE) instead of default export for route handlers","export\\s+default\\s+function","error",{"message":107,"pattern":108,"severity":105},"NextApiRequest\u002FNextApiResponse are Pages Router types — use Web API Request\u002FResponse","NextApiRequest|NextApiResponse",{"message":110,"pattern":111,"severity":112,"upgradeWhy":113,"upgradeToSkill":48,"skipIfFileContains":114},"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":116,"pattern":51,"severity":112,"upgradeWhy":117,"upgradeToSkill":52,"skipIfFileContains":118},"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":120,"pattern":121,"severity":105,"upgradeWhy":122,"upgradeToSkill":56,"skipIfFileContains":123},"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":125,"pattern":126,"severity":127,"upgradeWhy":128,"upgradeToSkill":129,"skipIfFileContains":130},"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","Add structured logging, error tracking, and OTel instrumentation to route handlers.","observability","console\\.error|logger\\.|captureException|Sentry|@vercel\u002Fotel|withTracing",{"message":132,"pattern":73,"severity":112,"upgradeWhy":133,"upgradeToSkill":74,"skipIfFileContains":75},"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":135,"pattern":78,"severity":112,"upgradeWhy":136,"upgradeToSkill":52,"skipIfFileContains":79},"Manual retry logic detected. Use Vercel Workflow DevKit for automatic retries with durable execution.","Replace manual retry loops with Workflow DevKit steps that provide automatic retries, crash safety, and observability.",{"message":138,"pattern":139,"severity":112,"upgradeWhy":140,"upgradeToSkill":5,"skipIfFileContains":141},"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":143,"intents":148,"entities":153},[144,145,146,147],"serverless functions","api routes","edge functions","lambda",[149,150,151,152],"create serverless function","configure function runtime","optimize cold starts","add api route",[154,155,156,32,157],"Serverless Functions","Edge Functions","Fluid Compute","Cron Jobs","main","9a4409c8751439c3aeeea2bc3940ba05dc3cd3b5","plugins\u002Fvercel\u002Fskills\u002Fvercel-functions",0,"https:\u002F\u002Fgithub.com\u002FNagyVikt\u002Fcodex-plugins","https:\u002F\u002Fgithub.com\u002FNagyVikt","https:\u002F\u002Fwebu.hu\u002F","Codex is a tool they said...\r\n\r\nCreator of GitGuardex, CueCards. Tech stack: Next.js · TypeScript · Rust · Linux. ","2026-03-30 02:19:53",{"source":8,"skillName":5,"commands":168,"prompt":178,"zipAvailable":179},[169,172,175],{"tool":170,"command":171},"npx","npx skills add NagyVikt\u002Fcodex-plugins --skill vercel-functions",{"tool":173,"command":174},"bunx","bunx skills add NagyVikt\u002Fcodex-plugins --skill vercel-functions",{"tool":176,"command":177},"pnpm","pnpm dlx skills add NagyVikt\u002Fcodex-plugins --skill vercel-functions","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002FNagyVikt\u002Fcodex-plugins\u002Fblob\u002Fmain\u002Fplugins\u002Fvercel\u002Fskills\u002Fvercel-functions\u002FSKILL.md",true,[],[182,203,223,241,262,284],{"skillNo":183,"name":52,"nameZh":6,"description":184,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":185,"categories":186,"keywords":187,"publishedAt":39},"01M6K1ZEN8P9R2S6NPNJNJ8JVH","Vercel Workflow DevKit (WDK) expert guidance. Use when building durable workflows, long-running tasks, API routes or agents that need pause\u002Fresume, retries, step-based execution, or crash-safe orchestration with Vercel Workflow.","https:\u002F\u002Fgithub.com\u002FNagyVikt\u002Fcodex-plugins\u002Fblob\u002Fmain\u002Fplugins\u002Fvercel\u002Fskills\u002Fworkflow\u002FSKILL.md",[],[52,188,189,190,32,38,191,192,37,193,194,195,196,197,198,199,200,201,24,202],"workflows","create","run","start","why","wait for","branch","auto","log","conversation","human","lib","condition","rendering","sleep",{"skillNo":204,"name":205,"nameZh":6,"description":206,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":207,"categories":208,"keywords":209,"publishedAt":39},"01M6K1Z71NWFSPHK2VJJ73MVSY","verification","Full-story verification — infers what the user is building, then verifies the complete flow end-to-end: browser → API → data → response. Triggers on dev server start and 'why isn't this working' signals.","https:\u002F\u002Fgithub.com\u002FNagyVikt\u002Fcodex-plugins\u002Fblob\u002Fmain\u002Fplugins\u002Fvercel\u002Fskills\u002Fverification\u002FSKILL.md",[],[205,210,32,211,212,213,194,214,215,216,22,30,217,27,218,219,105,220,221,222],"auth","routing middleware","api","projects","user story","full stack","jest","end","false","unit","middleware","loading","unit test",{"skillNo":224,"name":56,"nameZh":6,"description":225,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":226,"categories":227,"keywords":228,"publishedAt":39},"01M6K1YPRYJS3BQEDP8HKBHPEJ","Vercel storage expert guidance — Blob, Edge Config, and Marketplace storage (Neon Postgres, Upstash Redis). Use when choosing, configuring, or using data storage with Vercel applications.","https:\u002F\u002Fgithub.com\u002FNagyVikt\u002Fcodex-plugins\u002Fblob\u002Fmain\u002Fplugins\u002Fvercel\u002Fskills\u002Fvercel-storage\u002FSKILL.md",[],[229,230,20,231,190,232,233,195,36,234,34,235,236,28,27,199,237,238,239,240],"storage","vercel storage","config","supabase","migrate","clerk","prisma","connection pooling","turso","upstash","URL","auth0",{"skillNo":242,"name":243,"nameZh":6,"description":244,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":245,"categories":246,"keywords":247,"publishedAt":39},"01M6K1YFEP0GPPGMQ3D0FPTS27","vercel-services","Vercel Services — deploy multiple services within a single Vercel project. Use for monorepo layouts or when combining a backend (Python, Go) with a frontend (Next.js, Vite) in one deployment.","https:\u002F\u002Fgithub.com\u002FNagyVikt\u002Fcodex-plugins\u002Fblob\u002Fmain\u002Fplugins\u002Fvercel\u002Fskills\u002Fvercel-services\u002FSKILL.md",[],[248,249,20,250,251,252,253,254,255,256,257,158,258,259,30,260,27,26,105,261],"vercel services","services","frontend","docker compose","SET","configure","monorepo","go api","fastapi","up","aws lambda","go backend","get","python backend",{"skillNo":263,"name":264,"nameZh":6,"description":265,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":266,"categories":267,"keywords":268,"publishedAt":39},"01M6K1Y8S3CRD43DPKX0PK1MTT","vercel-sandbox","Vercel Sandbox guidance — ephemeral Firecracker microVMs for running untrusted code safely. Supports AI agents, code generation, and experimentation. Use when executing user-generated or AI-generated code in isolation.","https:\u002F\u002Fgithub.com\u002FNagyVikt\u002Fcodex-plugins\u002Fblob\u002Fmain\u002Fplugins\u002Fvercel\u002Fskills\u002Fvercel-sandbox\u002FSKILL.md",[],[269,270,20,271,272,189,190,273,274,275,276,277,278,279,280,281,221,282,264,283],"sandbox","vercel sandbox","safe","ai agents","code","ai sdk","Code Generation","playground","generated","spawn","install","runner","io","child","student",{"skillNo":285,"name":286,"nameZh":6,"description":287,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":288,"categories":289,"keywords":290,"publishedAt":39},"01M6K1Y1J8S7AN97H75SHBGF7J","vercel-queues","Vercel Queues guidance (public beta) — durable event streaming with topics, consumer groups, retries, and delayed delivery. $0.60\u002F1M ops. Powers Workflow DevKit. Use when building async processing, fan-out patterns, or event-driven architectures.","https:\u002F\u002Fgithub.com\u002FNagyVikt\u002Fcodex-plugins\u002Fblob\u002Fmain\u002Fplugins\u002Fvercel\u002Fskills\u002Fvercel-queues\u002FSKILL.md",[],[291,20,52,188,32,292,252,212,253,257,293,294,295,296,27,199,297,24,221,298],"vercel queues","beta","message","delivery","across","worker","processing","at"]