home / skills / bobmatnyc / claude-mpm-skills / vercel-functions-runtime

This skill helps you build and deploy Vercel Functions and Edge Runtime APIs, scheduling cron jobs and routing middleware for low-latency serverless apps.

npx playbooks add skill bobmatnyc/claude-mpm-skills --skill vercel-functions-runtime

Review the files below or copy the command above to add this skill to your agents.

Files (2)
SKILL.md
2.5 KB
---
name: vercel-functions-runtime
description: Vercel Functions and Edge Runtime, including cron jobs and routing middleware. Use when building APIs, serverless workloads, or scheduled tasks on Vercel.
progressive_disclosure:
  entry_point:
    summary: "Vercel Functions and Edge Runtime, including cron jobs and routing middleware. Use when building APIs, serverless workloads, or scheduled tasks on Vercel."
    when_to_use: "When working with vercel-functions-runtime or related functionality."
    quick_start: "1. Review the core concepts below. 2. Apply patterns to your use case. 3. Follow best practices for implementation."
---
# Vercel Functions and Runtime Skill

---
progressive_disclosure:
  entry_point:
    summary: "Vercel Functions and Edge Runtime: serverless APIs, edge execution, cron jobs, and routing middleware."
    when_to_use:
      - "When building API routes or serverless logic"
      - "When targeting the Edge Runtime"
      - "When scheduling tasks with cron jobs"
    quick_start:
      - "Create a function entry point"
      - "Choose the runtime (Node or Edge)"
      - "Configure cron schedules"
      - "Deploy and monitor"
  token_estimate:
    entry: 90-110
    full: 3600-4700
---

## Overview

Vercel Functions provide serverless execution for APIs and background tasks. The Edge Runtime enables low-latency execution closer to users.

## Vercel Functions

- Define serverless functions in the project structure.
- Use environment variables for configuration.
- Review logs for errors and performance.

## Edge Runtime

- Use the Edge Runtime for low-latency execution.
- Validate compatibility with the Edge runtime constraints.

## Cron Jobs

- Schedule jobs with cron definitions.
- Use cron for periodic maintenance tasks or sync jobs.

## Routing and Middleware

- Apply routing middleware for request handling.
- Use headers, rewrites, and redirects to control traffic.

## Complementary Skills

When using this skill, consider these related skills (if deployed):

- **vercel-deployments-builds**: Deployment workflow and release controls.
- **vercel-networking-domains**: Routing, headers, and edge caching.
- **vercel-observability**: Logs and tracing for function debugging.

*Note: Complementary skills are optional. This skill is fully functional without them.*

## Resources

**Vercel Docs**:
- Functions: https://vercel.com/docs/functions
- Edge Runtime: https://vercel.com/docs/functions/runtimes/edge
- Cron Jobs: https://vercel.com/docs/cron-jobs
- Routing Middleware: https://vercel.com/docs/routing-middleware

Overview

This skill exposes Vercel Functions and the Edge Runtime for building serverless APIs, low-latency edge code, scheduled cron jobs, and routing middleware. It helps you structure functions, pick the right runtime, and manage scheduled tasks and request routing for production workloads.

How this skill works

I guide you to create function entry points, select Node or Edge runtimes, and wire environment variables and secrets for runtime configuration. I show how to declare cron schedules and attach routing middleware to handle headers, rewrites, and redirects. I also recommend log and observability checks to monitor execution, latency, and errors.

When to use it

  • Building REST or GraphQL API routes that scale without server management
  • Running latency-sensitive code close to users using the Edge Runtime
  • Scheduling periodic background work or maintenance via cron jobs
  • Applying middleware for routing, header control, rewrites, or access rules

Best practices

  • Choose Edge Runtime only for compatible, stateless code and small dependencies
  • Keep functions small and single-purpose to reduce cold start and simplify testing
  • Store secrets and environment variables in Vercel settings, not in code
  • Use cron jobs for idempotent maintenance tasks and add retry/error handling
  • Instrument functions with logs and tracing to detect performance regressions

Example use cases

  • A public API endpoint for a web app that scales automatically with traffic
  • Personalization or A/B logic executed at the edge for faster responses
  • Nightly data cleanup or sync tasks triggered by cron schedules
  • Middleware that enforces authentication and rewrites paths before routing
  • Small serverless workers that transform requests or responses on the edge

FAQ

When should I prefer Edge Runtime over a Node function?

Prefer Edge for low-latency, geolocated execution and small stateless handlers; use Node for heavier dependencies or long-running tasks.

How do I run scheduled jobs reliably?

Define cron schedules in project configuration, make tasks idempotent, add retries and idempotency keys, and monitor runs via logs or observability tools.