> ## Documentation Index
> Fetch the complete documentation index at: https://www.usenotra.com/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Track AI crawlers on Next.js

> Install the @usenotra/geo tracker in a Next.js app to log AI crawlers, AI-cited fetches and AI referrals in Notra.

This guide adds the Notra tracker to a Next.js app, which takes about five minutes and one file, `proxy.ts`.

<Tip>
  The Traffic page has a **Copy agent prompt** button. Paste it into Claude Code, Cursor or Codex and the agent will do these steps for you.
</Tip>

<Steps>
  <Step title="Get your token">
    Open **Traffic** in the GEO sidebar. Until the first event arrives, the page shows **No activity yet** along with the full install panel, which has **Install the package**, **Set your token** and **Add the proxy** sections. Your token appears in the **Set your token** section, and the panel also has a **Copy agent prompt** button that copies an instruction block you can paste into a coding agent.

    From the API, reading the snippets needs `traffic.read` and issuing the token needs `traffic.write`:

    ```bash theme={"system"}
    curl https://api.usenotra.com/v1/geo/ingest/setup \
      -H "Authorization: Bearer $NOTRA_API_KEY"
    ```

    ```bash theme={"system"}
    curl -X POST "https://api.usenotra.com/v1/geo/ingest/token?projectId=$PROJECT_ID" \
      -H "Authorization: Bearer $NOTRA_API_KEY"
    ```

    Both return `ingestUrl`, `snippet` (the Next.js snippet) and `snippets` with `next`, `nuxt`, `tanstack`, `astro`, `sveltekit` and `netlify` keys, and the token endpoint adds `token`. The ingest routes are organization-level, so pass `projectId` to bind the token to one project or omit it to track the whole organization. Issuing a token does not invalidate tokens issued earlier.

    Install the same project token on every domain the project tracks, and add extra hostnames under **Tracked domains** in GEO settings.
  </Step>

  <Step title="Install the package">
    <CodeGroup>
      ```bash npm theme={"system"}
      npm install @usenotra/geo
      ```

      ```bash yarn theme={"system"}
      yarn add @usenotra/geo
      ```

      ```bash pnpm theme={"system"}
      pnpm add @usenotra/geo
      ```

      ```bash bun theme={"system"}
      bun add @usenotra/geo
      ```
    </CodeGroup>

    The package has zero dependencies and no Node APIs in the core, so it runs on edge runtimes.
  </Step>

  <Step title="Set the environment variable">
    Add the token as `NOTRA_GEO_TOKEN` in your site's environment variables, both locally and at your hosting provider, and never hardcode or commit it.
  </Step>

  <Step title="Add the tracker">
    ```typescript proxy.ts theme={"system"}
    import { createGeoProxy } from "@usenotra/geo/next";
    import { after, NextResponse } from "next/server";

    const geo = createGeoProxy({
      token: process.env.NOTRA_GEO_TOKEN!,
      endpoint: "https://ingest.usenotra.com",
    });

    export function proxy(request: Request) {
      after(() => geo(request));
      return NextResponse.next();
    }
    ```

    Use `proxy.ts` on Next.js 16 and `middleware.ts` on earlier versions. `geo(request)` never throws and never blocks the response.
  </Step>

  <Step title="Deploy and verify">
    After you deploy your site, the Traffic page switches from the install panel to the dashboard as soon as Notra stores the first AI crawler or referral. Crawlers visit on their own schedule, so the first event can take a while on a quiet site.
  </Step>
</Steps>

## Next steps

<Columns cols={2}>
  <Card title="Tracker reference" icon="sliders" href="/docs/ai-traffic/tracker-reference">
    Options, excluded paths, privacy and token rotation.
  </Card>

  <Card title="Journey tagging" icon="route" href="/docs/ai-traffic/journeys">
    Follow one agent across the pages it reads.
  </Card>
</Columns>


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.