# Install Intercrawl

Intercrawl serves a fully rendered page to search engine and AI crawlers for JavaScript sites, and shows what each crawler received. This page is written for AI coding assistants. A person can also give it to their assistant with a request such as: add Intercrawl to this project.

## What to do

Add Intercrawl to this project, so search engine and AI crawlers receive a fully rendered page. Visitors must not be affected in any way.

Intercrawl renders JavaScript pages for crawlers. The change is a small piece of server code that asks Intercrawl for the rendered page when a request comes from a known crawler, and otherwise lets the request continue exactly as it does today. If Intercrawl does not answer in time, the normal page is served.

Steps
1. Download the install file that matches how this project is deployed. It is one file with no dependencies of its own. Use it exactly as it is and do not rewrite it:
   - Next.js: https://intercrawl.com/install/v1/next.ts
   - Vercel, any framework other than Next.js: https://intercrawl.com/install/v1/vercel.ts
   - Netlify: https://intercrawl.com/install/v1/netlify.ts
   - a Cloudflare Worker in front of the site: https://intercrawl.com/install/v1/worker.ts
   - Cloudflare Pages: https://intercrawl.com/install/v1/pages.ts
   Choose the one that matches how this project is deployed.
2. Read the comment block at the top of the file. It says where to save it and how to combine it with an existing middleware.
3. If the project already has a middleware file (middleware.ts, or proxy.ts on Next.js 16 and later), do not replace it. Save the install file elsewhere in the project, for example lib/intercrawl.ts, and add the call shown in the file's comment at the top of the existing function, so Intercrawl runs first and everything else stays as it is.
4. On Next.js 16 and later the file is called proxy.ts and its function is named proxy; middleware.ts with a function named middleware still works there and is deprecated. Follow the convention the project already uses, and use proxy.ts when you create a new file on Next.js 16 or later.
5. The code reads the token from the environment variable INTERCRAWL_TOKEN. Never write a token into a file or commit one.
6. If the file needs a helper package (the Vercel file needs @vercel/functions), add it with the project's package manager.

Rules
- Change nothing else: no other routes, API handlers, webhooks, authentication or configuration.
- Keep the existing middleware's matcher and behaviour. Intercrawl must only act on crawler requests.
- Add no other dependencies.
- If the project is a static export with no server code, stop and tell me instead of guessing.

When you are done
- Show me the diff.
- Tell me to add the environment variable INTERCRAWL_TOKEN where the app runs. I create the token in Intercrawl under Account, API tokens.
- After I deploy, I press Check install on the Sites page at https://intercrawl.com/sites.

## The install files

- Next.js: https://intercrawl.com/install/v1/next.ts
- Vercel, any framework other than Next.js: https://intercrawl.com/install/v1/vercel.ts
- Netlify: https://intercrawl.com/install/v1/netlify.ts
- a Cloudflare Worker in front of the site: https://intercrawl.com/install/v1/worker.ts
- Cloudflare Pages: https://intercrawl.com/install/v1/pages.ts

## The token

A person creates an API token in their Intercrawl account under Account, API tokens (https://intercrawl.com/account). It starts with ic_live_ and is set as the environment variable INTERCRAWL_TOKEN where the app runs. An assistant never needs to see it.
