app/root.tsx is the single file that renders the full HTML document for every route in your application. It exposes a <Scripts /> component that Remix uses to inject your app’s JavaScript — and it is the right place to add the Subtext capture snippet so it loads on every page. You will add an inline <script> tag just before <Scripts /> inside the <body>.
You can also run
npx @subtextdev/subtext-wizard in your project root to have Subtext detect your framework and insert the snippet automatically. Follow this guide if you prefer to wire things up by hand.1
Find your Org ID
Log in to Subtext and open Settings. Your Org ID is listed in the Capture section. Copy it — you will paste it in place of
YOUR_ORG_ID in the snippet below.2
Open app/root.tsx
Open
app/root.tsx (or app/root.jsx) in your editor. Look for the App component (or whichever component exports <html>…</html>) — this is where you will add the snippet.3
Add the capture snippet before Scripts
Insert a
<script> tag containing the capture snippet just before the <Scripts /> component inside the <body>. Replace YOUR_ORG_ID with the Org ID you copied from Subtext settings.app/root.tsx
Remix performs server-side rendering, so you must use
dangerouslySetInnerHTML to embed an inline script. This is safe here because the snippet content is static and does not include any user-generated input.4
Start your dev server
Run
npm run dev and open your application in a browser. The snippet is injected server-side into every response, so it will fire on initial page load as well as on client-side navigations.5
Verify capture is working
Navigate to a few routes, then open Subtext → Sessions. A new session should appear within a minute or two.
The snippet records full production sessions and masks all form inputs by default. Your agent can flag additional PII and propose masking rules for your review from within Subtext.

