init() loads the script for you.
Install Bily
Track every route once
This example uses React Router. It remembers the initial URL so it does not send a secondPageView, then ignores repeated calls for the same URL.
src/bily-tracking.tsx
useLocation() observe committed routes without creating a second router.
src/AppRoutes.tsx
react-router-dom to be installed and a router to exist above AppRoutes. Do not add another BrowserRouter, Router, or RouterProvider.
Repeated init() calls with the same URL are safe. One component keeps ownership clear, while the URL guard prevents React development checks from creating duplicate route events.
Track successful actions
Calltrack() only after the user action succeeds.
src/LaunchCampaignButton.tsx
Verify React Router
Check the initial view, later routes, and action events without duplicates.
Use framework mode
Install Bily in a React Router framework mode or Remix root route.