Security
Rate Limit
Built-in rate limiting to secure your APIs and Server Actions against abuse, spam, and brute-force attacks.
Demo
Setup
Create a free account on Upstash, choose the Redis product, then copy your credentials and paste them into your .env file:
Protect your APIs
You can configure rate limits for your APIs by adding them to the lib/rate-limit/config.ts file. Any API route not defined in this config will share a combined limit of 100 requests per minute.
Rate limits for APIs are only enforced in production so you don’t consume your Upstash quota during development.
Protect your Server Action
Add rate limiting inside your server action.
Configure the server action limits
Configure the rate limit for your server action by adding it to the same lib/rate-limit/config.ts file.