Provides a rate limiting middleware pattern for Next.js API routes and Server Actions.
Uses Upstash Redis (serverless-compatible) with sliding window algorithm.
When to use
Any public-facing API route
Auth endpoints (login, signup, password reset) — most critical
Any endpoint that triggers expensive operations (email, payment, AI inference)
Import and use in route handlers following the route-handler-template.ts pattern.
Limits (starting point — tune to your traffic)
Auth endpoints: 5 requests / 15 minutes per IP
General API: 60 requests / minute per IP or user ID
AI/expensive endpoints: 10 requests / hour per user
1---2name: api-rate-limiter3description: Skill: api-rate-limiter4---56# Skill: api-rate-limiter78Provides a rate limiting middleware pattern for Next.js API routes and Server Actions.9Uses Upstash Redis (serverless-compatible) with sliding window algorithm.1011## When to use12- Any public-facing API route13- Auth endpoints (login, signup, password reset) — most critical14- Any endpoint that triggers expensive operations (email, payment, AI inference)1516## Files17- `rate-limiter.template.ts` — Rate limiter middleware1819## Setup201. Install: `pnpm add @upstash/ratelimit @upstash/redis`212. Add to `.env.example`:22 ```23 UPSTASH_REDIS_REST_URL= # Upstash Redis REST URL24 UPSTASH_REDIS_REST_TOKEN= # Upstash Redis REST token25 ```263. Import and use in route handlers following the `route-handler-template.ts` pattern.2728## Limits (starting point — tune to your traffic)29- Auth endpoints: 5 requests / 15 minutes per IP30- General API: 60 requests / minute per IP or user ID31- AI/expensive endpoints: 10 requests / hour per user
Run npx skillmds@latest add gabrielmoreira/api-rate-limiter in your terminal (requires Node.js), paste this page's agent-chat prompt into Claude, Cursor, or any MCP-connected agent, or download the SKILL.md file and copy it into your agent's skills directory.
Skill: api-rate-limiter It is listed under Integrations & APIs on SkillMD.
This skill has not completed SkillMD's automated safety review yet. Independent scanners report: SkillSpector: PASS, Skill Scanner: PASS. SkillMD never runs a skill's scripts for you; review the SKILL.md before installing.
This skill is tagged as working with Claude Code, Claude.ai, OpenAI Codex. SKILL.md is an open format, so most agents that read a skills directory can load it too.
Yes. Installing skills from SkillMD is free, and the skill stays under its author's original license.
gabrielmoreira (@gabrielmoreira) published this skill. Their other Agent Skills are listed on their SkillMD profile.