Skip to main content

Install Trfyx in React Router

Add the Trfyx tracker once at the application’s root so it is available across routes.

Add the tracker

Open your root component, commonly App.jsx, App.tsx, or your application entry point, and load the Trfyx tracker once.
Replace YOUR_TRFYX_PROJECT_ID with the Website ID from your Trfyx project and yourdomain.com with the domain you want to track. Keep the script URL as https://app.trfyx.com/script.js.
Add the tracker once at the application root. Do not add it inside individual route components, or you may collect duplicate pageviews.

Verify route tracking

Deploy the app, visit the live site, and navigate through several React Router routes. Confirm that Trfyx receives the expected activity. Do not mount the tracker separately inside every route component. That can create duplicate scripts and duplicate collection.
Last modified on October 11, 2026