Skip to main content

Documentation Index

Fetch the complete documentation index at: https://docs.searchable.com/llms.txt

Use this file to discover all available pages before exploring further.

What this does

An Edge Function runs at Netlify’s edge in front of your origin. For every inbound request it:
  1. Lets the request pass through to your origin unchanged (no added latency for users)
  2. After the response is returned, fires a fire-and-forget POST to Searchable with the request metadata
  3. Returns the original response to the visitor
Searchable classifies the user agent server-side and records it if it matches a known AI crawler.
Works on every Netlify plan, including Free. Netlify’s free plan covers 1M Edge Function invocations per month — well above typical bot traffic for most sites.

Prerequisites

A Netlify site with deploy access
A Searchable project with your domain confirmed

Setup

1

Generate an integration token in Searchable

  1. Open your Searchable dashboard
  2. Go to Agent Analytics → Setup
  3. Pick Netlify Edge Function as your crawler source
  4. Click Generate token
Copy the token now — it starts with sa_… and won’t be shown again. You can always generate a new one if you lose it.
2

Add the Edge Function file to your repo

Create the file netlify/edge-functions/searchable.ts in your repository and paste the snippet below.
netlify/edge-functions/searchable.ts
import type { Context } from "https://edge.netlify.com";

const ENDPOINT = "https://searchable-tracker.searchable.workers.dev/v1/netlify-edge";
const TOKEN = Netlify.env.get("SEARCHABLE_TOKEN");

export default async function (request: Request, context: Context) {
  const response = await context.next();
  context.waitUntil(forward(request, response, context));
  return response;
}

async function forward(request: Request, response: Response, context: Context) {
  if (!TOKEN) return;
  try {
    const url = new URL(request.url);
    await fetch(ENDPOINT, {
      method: "POST",
      headers: { "content-type": "application/json", authorization: `Bearer ${TOKEN}` },
      body: JSON.stringify({
        type: "netlify_edge_event",
        timestamp: Date.now(),
        request_id: request.headers.get("x-nf-request-id") ?? crypto.randomUUID(),
        method: request.method,
        path: url.pathname,
        url: request.url,
        status_code: response.status,
        user_agent: request.headers.get("user-agent") ?? "",
        ip_address: context.ip ?? "",
        country: context.geo?.country?.code ?? "",
        referrer: request.headers.get("referer") ?? "",
      }),
    });
  } catch {
    /* swallow */
  }
}

export const config = { path: "/*" };
The function intercepts every request, forwards a lightweight event to Searchable after the response is returned, and never blocks the user.
3

Add the environment variable in Netlify

In your Netlify site:Site settings → Environment variables → Add a variable
KeyValue
SEARCHABLE_TOKENThe sa_… token you generated above
Make sure the variable name is exactly SEARCHABLE_TOKEN (all caps, underscore).
4

Commit and push

Commit the new file and push to your main branch. Netlify will auto-deploy the edge function.
git add netlify/edge-functions/searchable.ts
git commit -m "Add Searchable edge function"
git push
5

Verify the function is active

In Netlify, open Site settings → Edge functions and confirm that searchable appears in the list and is marked active.

Verifying the connection

Return to Agent Analytics → Setup in your Searchable dashboard. The Netlify Edge Function card should flip to Connected within about 10 seconds of the next AI crawler hitting your site.
StatusWhat it means
Waiting for first eventThe function is deployed but no AI bot has hit your site yet. Typical wait is a few hours for sites that are already indexed.
ConnectedEvents are arriving. The card shows the count from the last 24 hours.

Cost

Each forwarded request consumes one Edge Function invocation. Netlify’s free plan covers 1M invocations per month — bot traffic is a tiny fraction of that for typical sites.

Troubleshooting

Check these in order:
  • The environment variable is named exactly SEARCHABLE_TOKEN (all caps, underscore — not SearchableToken or SEARCHABLE-TOKEN)
  • The deploy succeeded — check Netlify’s deploy log for errors in the edge function
  • The function is active in Site settings → Edge functions
  • The config export at the bottom of the file sets path: "/*" so the function runs on all requests
That’s expected. Searchable filters non-bot user agents server-side — only AI crawlers (GPTBot, ClaudeBot, PerplexityBot, etc.) are recorded in your dashboard. Human visitors are forwarded but immediately discarded.
If the function throws during context.next(), Netlify may surface it in deploy logs. The forward() call is wrapped in a try/catch and uses context.waitUntil(...), so errors inside forward are silently swallowed and never affect your visitors.Confirm the function file is valid TypeScript and that the import type { Context } line is present — Netlify’s Deno runtime requires it.

Removing the integration

  1. Delete netlify/edge-functions/searchable.ts from your repo and push
  2. Netlify → Site settings → Environment variables → remove SEARCHABLE_TOKEN
  3. Searchable → Agent Analytics → Setup → Tokens → revoke the token

Next steps

See the data

Open Agent Analytics to see which assistants are crawling your site.

Add Search Console

Correlate AI crawls with search demand.