Install Foresite on React Router and Remix
In React Router's framework mode and in Remix, the whole page comes from app/root.tsx. Paste your Foresite line into the <head> of its Layout:
import { Links, Meta, Outlet, Scripts, ScrollRestoration } from 'react-router'
export function Layout({ children }: { children: React.ReactNode }) {
return (
<html lang="en">
<head>
<meta charSet="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<Meta />
<Links />
<script defer src="https://t.foresite.dev/s/YOUR_SITE_ID.js" />
</head>
<body>
{children}
<ScrollRestoration />
<Scripts />
</body>
</html>
)
}
export default function App() {
return <Outlet />
}
In Remix, the imports come from @remix-run/react instead; the rest is the same. Use the address from your own Foresite line (Settings → Install).
Foresite counts each client-side page change as a pageview automatically. Visits to localhost aren't counted, so test on your deployed site: the Installation Check in Settings → Install turns green with the first pageview.