createFetchMiddleware returns a function with this shape:
Install
.env
src/lib/beacon.ts
Wiring it up
Nuxt
Nuxt is the awkward one. Nitro middleware runs before the route handler and cannot wrap its response, socreateFetchMiddleware does not fit. Serving twins and reporting hits still work; advertising the twin on HTML responses has to be done by hand.
server/middleware/beacon.ts
The
Vary: Accept line is not optional. Without it a cache can hand the HTML copy to a client that asked for Markdown, or the reverse.Serverless runtimes
On Workers, Netlify Edge and similar, pass the platform’s waiting context so a pending report is not killed when the response returns. The snippets above already do:Options
endpoint accepts a bare origin; the ingest path is appended for you. See self-hosting to run your own, and the SDK reference for every option.
