Back to Templates

Ratelimit your Next.js routes

Using @unkey/ratelimit to protect your API routes from abuse

Written by
chronark
Framework
Next.js
Language
Typescript
Using @unkey/ratelimit to protect your API routes from abuse

This is a Next.js project bootstrapped with create-next-app.

Getting Started

Go to unkey.dev and create a new root key. The onboarding flow will create one for you. Take the root key and create a .env.local file in the root of the project. Add the following line to the file:

1UNKEY_ROOT_KEY=your_root_key_here

Then, run the development server:

1npm run dev
2# or
3yarn dev
4# or
5pnpm dev
6# or
7bun dev

Open http://localhost:3000/simple with your browser to see the result.

Protect your API.
Start today.

2500 verifications and 100K successful rate‑limited requests per month. No CC required.