Install · runtime

The agent on Vercel

Before the response. On Vercel the agent is one middleware file at the project root.

How it works on Vercel

On Vercel the agent is one middleware file at the project root. It runs at the edge before the response, with any framework or none.

The file

middleware.js — At your project root. Works with or without a framework.

import { next } from '@vercel/edge'
import { reflexa } from './reflexa-agent.js'

const agent = reflexa({ token: process.env.REFLEXA_TOKEN })

export default async function middleware(request, context) {
  try {
    return (await agent.ahead(request, context)) ?? next()
  } catch {
    return next() // never let the agent take the site down
  }
}

export const config = { matcher: '/:path*' }

Get reflexa-agent.js and the site's token from the dashboard's Agent page, put the token in REFLEXA_TOKEN, deploy. Then press Check the connection in the dashboard: it fetches the domain proof from your real domain and the agent is live.

What you can measure

  • records AI crawler requests and referrals by page
  • verifies the site connection using the domain proof

Go deeper on reflexatechnologies.com: the Vercel guide · check your site's AI crawler access first (free)

All install guides → · Data and privacy →

Questions people ask

Do I need to connect my site for the first check?

A public URL is enough for the external diagnosis. A supported site connection adds AI request and referral data.

Can I take it out?

Remove the integration from the runtime and redeploy to stop reporting new traffic. Your saved reports remain in the dashboard.

Which data does this connection add?

Records AI crawler requests and referrals by page. Verifies the site connection using the domain proof.

Is the token a secret?

Yes. It belongs to this one site and should live in an environment variable, never in a file you commit. It grants nothing beyond this site, and the domain proof refuses it from any other host.

Find your next search opportunity.

Get your free report with 40+ checks. See which pages need attention, why they matter and where to start.

Create a free account in the next step for the full diagnosis.