
Security News
Meet Socket at Black Hat Europe and BSides London 2025
Socket is heading to London! Stop by our booth or schedule a meeting to see what we've been working on.
next-rate-limit
Advanced tools
Update to [next.js Api Route Limiting Example](https://github.com/vercel/next.js/tree/canary/examples/api-routes-rate-limit)
Update to next.js Api Route Limiting Example
# Using npm
> npm install next-rate-limit
# Using yarn
> yarn add next-rate-limit
# Using pnpm
> pnpm add next-rate-limit
import rateLimit from 'next-rate-limit';
import rateLimit from 'next-rate-limit';
import { NextRequest, NextResponse } from 'next/server';
const limiter = rateLimit({
interval: 60 * 1000, // 1 minute
uniqueTokenPerInterval: 500 // Max 500 users per minute
});
export function GET(req: NextRequest) {
try {
const headers = limiter.checkNext(req, 10);
return NextResponse.json(
{
limit: headers.get('X-RateLimit-Limit'),
remaining: headers.get('X-RateLimit-Remaining')
},
{ headers }
);
} catch {
return NextResponse.json({ error: 'Rate limit exceeded' }, { status: 429 });
}
}
See original repo linked for full example.
interval
number
See lru-cache ttl
Defaults to 60000 ms (= 1 minute).
uniqueTokenPerInterval
number
See lru-cache max
Defaults to 500.
FAQs
Update to [next.js Api Route Limiting Example](https://github.com/vercel/next.js/tree/canary/examples/api-routes-rate-limit)
The npm package next-rate-limit receives a total of 2,513 weekly downloads. As such, next-rate-limit popularity was classified as popular.
We found that next-rate-limit demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Socket is heading to London! Stop by our booth or schedule a meeting to see what we've been working on.

Security News
OWASP’s 2025 Top 10 introduces Software Supply Chain Failures as a new category, reflecting rising concern over dependency and build system risks.

Research
/Security News
Socket researchers discovered nine malicious NuGet packages that use time-delayed payloads to crash applications and corrupt industrial control systems.