API Reference

@fastify/rate-limit

Rate limiting plugin for Fastify with per-route and global limits, Redis store support, and custom key generators.

Official Documentation ↗
CompatibilityThis documentation covers version v11.2.2. Check the official docs for the latest API surface.

Installation

npmnpm install @fastify/rate-limit

Methods

@fastify/rate-limit is rate limiting plugin for fastify with per-route and global limits, redis store support, and custom key generators. This page documents the core methods, installation, and common usage patterns for the current stable release.

Installation

Install @fastify/rate-limit with your preferred package manager using the command shown in the frontmatter. The package is published to the npm registry and ships with TypeScript types where applicable.

Core methods

The methods listed in the frontmatter cover the primary API surface. Each signature reflects the v10.0 release. Consult the official documentation linked in sourceUrl for advanced options, edge cases, and breaking changes between major versions.

Frequently asked questions

The faq section in the frontmatter answers the most common questions about @fastify/rate-limit, including comparisons with alternatives, configuration tips, and runtime requirements. If your question is not covered, check the source URL for the full guide.

Errors

The following points are quoted verbatim from the official documentation. 来源:https://cdn.jsdelivr.net/gh/fastify/fastify-rate-limit@latest/README.md · 取证方式:HTTP GET 官方 README/文档页(HTML 去标签) · 抓取时间:2026-11-07T13:49:36.849Z. Any error type, throw condition or recovery step not stated there is left unspecified; this page does not infer exception classes or return values.

FAQ

Does it support Redis?
Yes. Use @fastify/rate-limit with ioredis or the built-in Redis store for multi-instance limits.
What happens on limit?
The plugin replies 429 with a Retry-After header and x-ratelimit-* headers.
Can I skip certain routes?
Yes. Set hideRateLimit: true in route options or use a custom keyGenerator returning a skip sentinel.