I am using Next Js 14 and Mongo DB.
In Node Js, we can use Express Rate Limit package to control website users requests number. if a user requests to the website more 200 times in 15 minutes, the package block that user for 15 minutes.
how can I do this work in Next Js 14 App router? thanks for your responses
Using @upstash/ratelimit which is recommended by next.js docs
You somehow keep track of each user, because you allow each user 200 requests. Vercel KV is a durable Redis database that enables you to store and retrieve simple key-value data structures globally at the edge.
If you do not want to use third party packages, you can follow this rate-limiting-serverless-functions
It uses a Sliding Window Technique: