Rate limiting is a critical technique to ensure the stability and performance of your system. By controlling the number of requests a user or client can make within a given time frame, you protect your API from overuse, abuse, or even potential attacks, like DDoS. TurboStack uses Upstash packages to apply rate limiting into our application.Documentation Index
Fetch the complete documentation index at: https://docs.turbostack.io/llms.txt
Use this file to discover all available pages before exploring further.
Setup Upstash
- Sign up on Upstash
- Create a new Redis Database.
- Add the
UPSTASH_REDIS_REST_URLandUPSTASH_REDIS_REST_TOKENinto your.env.localfile.
Rate limiting an API Route
TurboStack have an util function calledratelimit, resided at apps/web/lib/upstash/ratelimit.ts.