The Next.js adapter runs inside Next.js middleware, which means LintLiot intercepts every request at the Edge — before routing, before server components, and before API route handlers. You get WAF protection, bot detection, rate limiting, and anomaly detection with zero changes to your page or API code.Documentation Index
Fetch the complete documentation index at: https://docs.lintliot.com/llms.txt
Use this file to discover all available pages before exploring further.
Prerequisites
- Next.js 13.4 or later with the App Router enabled.
@lintliot/sdkinstalled. See Install the LintLiot SDK.LINTLIOT_API_KEYset in your environment.
Set up middleware
Create or updatemiddleware.ts at the root of your project (the same level as app/):
middleware.ts
matcher pattern above protects every route while excluding Next.js internals and static assets. Adjust it to match your routing needs.
withLintliot returns a standard Next.js middleware function. You can chain it with other middleware libraries that accept the same signature.How it works
When a request arrives,withLintliot runs these checks in order — all before your app code executes:
- IP intelligence — checks against the global LintLiot blocklist and your per-app rules.
- Bot detection — scores the request across 12 browser fingerprint signals.
- WAF — matches against 150+ patterns covering SQLi, XSS, SSRF, path traversal, and more.
- Rate limiting — enforces baseline-relative or configured request limits per IP.
- Permission check — optionally verifies the authenticated user has a required permission.
- Anomaly detection — flags traffic that deviates from your app’s learned behavioral baseline.
- Route sensitivity — applies automatic extra protection to admin, payment, export, and other sensitive route patterns.
403 or 429 JSON response. Allowed requests pass through to NextResponse.next() with security headers attached.
Protect specific routes only
To limit protection to API routes, update thematcher:
middleware.ts
middleware.ts
Configure rate limits and WAF mode
Pass aprotect object to customize protection options:
middleware.ts
headers: true injects security headers — CSP, HSTS, X-Frame-Options, Referrer-Policy, and others — into every passing response.
Protect individual route handlers
For fine-grained permission checks on a specific API route, useprotectRoute:
app/api/admin/users/route.ts
protectRoute extracts the user ID from the request headers (supporting Clerk, NextAuth, and Supabase conventions) and checks the permission against LintLiot IAM before calling your handler. Unauthenticated requests receive 401; unauthorized requests receive 403.
Skip specific paths
To exclude routes from protection — such as health checks — useskipRoutes:
middleware.ts
Environment variable setup
.env.local
NEXT_PUBLIC_ prefix, so LINTLIOT_API_KEY stays server-only.
Edge runtime compatibility
The Next.js adapter is fully compatible with the Edge Runtime. It uses only Web-standard APIs (fetch, Request, Response, Headers) and does not import any Node.js built-ins. You can deploy to Vercel Edge Functions, Cloudflare Pages, or any Edge-compatible environment without additional configuration.
