Prerequisites
- Created your Unkey account
 - Created an Unkey root key with 
ratelimit.*.create_namespaceandratelimit.*.limitpermissions. 
1
Create Next.js Application
Run the following command to init your Next.js project
- npm
 - pnpm
 - yarn
 - bun
 
2
Install
Now install the 
@unkey/ratelimit package- npm
 - pnpm
 - yarn
 - bun
 
3
Add Root Key to env
Add your root key to your 
.env file4
Creating a protected route
Create a new route and add the following code
/app/protected/route.ts
5
Running it
- npm
 - pnpm
 - yarn
 - bun
 
6
Try it out
Go to https://app.unkey.com and create a new key. Then verify it with our new server:You will need to curl a few times to see the ratelimiting error. Once you do, you, you will need to wait to perform the action again.