Install guides

Install on Next.js

One middleware file for a Next.js app, wherever it is hosted.

Steps

  1. Create an API token on the Account page and copy it.
  2. Add INTERCRAWL_TOKEN with the token as its value to the environment where your app runs (on Vercel: Project settings, Environment variables).
  3. Save the install file at the root of your project, next to package.json (or as src/middleware.ts if your app uses src/):
  1. Deploy, then press Check install on the Sites page.

Next.js 16 and later

The convention there is called proxy.ts, with the function named proxy. middleware.ts still works and is deprecated. If your project already uses proxy.ts, follow it.

If you already have a middleware

Do not replace it. Save the install file elsewhere, for example lib/intercrawl.ts, and call it at the top of your own function:

import { intercrawl } from "@/lib/intercrawl"; // adjust the path to the file

export async function middleware(request: NextRequest) {
  const page = await intercrawl(request);
  if (page) return page;
  // your middleware as before
}

intercrawl(request) answers only crawler requests and returns nothing for everyone else, so the rest of your middleware runs as before. Keep your existing matcher.