Back to Templates

Ratelimit your Next.js routes

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

Next.js
Framework
Typescript
Language
by chronark
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:

UNKEY_ROOT_KEY=your_root_key_here

Then, run the development server:

npm run dev
# or
yarn dev
# or
pnpm dev
# or
bun dev

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