Skip to main content
The proxy runs in your app’s server entry. It answers the proxy path and hands every other request to the app. Read how the proxy works first if you have not set one up before. Replace YOUR_SITE_ID and YOUR_PROXY_PATH with your own values. Site settings › Installation shows both, with this code already filled in. Generate the site secret there too.
1

Install the package

2

Add the environment variables

In .env. Set HIGHSEAT_PATH for the build as well as the server, as a build argument in a Docker build.
.env
3

Add the proxy to your server entry

Answers the proxy path and hands every other request to the app. A file route named after the path does not work: a catch-all route such as $id matches it first. “cloudflare” assumes a proxied Cloudflare record in front of the site; behind nginx alone, use “nginx”.
src/server.ts
4

Give the browser the same path

vite.config.ts
5

Load the tracker from the path

src/routes/__root.tsx
Deploy, then check the proxy. The card in Installation settings turns green when an event arrives through it.

Pick the IP preset

The code uses cloudflare, which fits a site behind a proxied Cloudflare record, even with nginx or Traefik in between. Behind nginx alone, use nginx. Pick the IP preset lists every preset.

Why the server entry

A file route named after the proxy path does not work: a catch-all route such as $id matches the path first. The server entry sees the request before the router does.

Set the path for the build

The define in vite.config.ts copies HIGHSEAT_PATH into the browser bundle, so <Highseat /> loads from the path the server answers. Set HIGHSEAT_PATH for the build as well as for the server, as a build argument in a Docker build. The define loads that one variable alone, so the site secret never reaches the bundle.

An app that reads the server entry’s options

fallback receives the request alone, so the app loses the options the server entry was called with. If your app reads them, create the proxy without fallback and route the path yourself. In the server entry’s fetch, call the proxy when the request’s pathname equals HIGHSEAT_PATH, and handler.fetch(request, options) for every other request.