Skip to content

Latest commit

 

History

History

nextjs-14-clerk-rl

Arcjet Logo

Arcjet Rate Limit / Clerk Authentication Example

This example shows how to use an Arcjet rate limit with a user ID from Clerk authentication and Next.js.

It sets up the /api/arcjet route.

  • Unauthenticated users receive a low rate limit based on the user IP address.
  • Users authenticated with Clerk have a higher rate limit based on the Clerk user ID.
  • A bot detection rule is also added to check all requests.

How to use

  1. From the root of the project, install the SDK dependencies.

    npm ci
  2. Enter this directory and install the example's dependencies.

    cd examples/nextjs-14-clerk-rl
    npm ci
  3. Rename .env.local.example to .env.local and add your Arcjet and Clerk keys.

  4. Start the dev server.

    npm run dev
  5. Visit http://localhost:3000.

  6. Try the different routes linked on the page.