Skip to main content
In a React single-page app, the simplest way to install Radar is to paste the script into the HTML file that hosts your app. Every screen of the app is served from that one file, so the script loads everywhere. Replace pk_xxxx with your project key. The file is index.html at the root of a Vite project, and public/index.html in a Create React App project.
index.html
For what each attribute does, see how the script works.

Alternative: React Helmet

If your app already manages the document head with React Helmet, add the script there. The condition skips the script when no key is set.
src/App.tsx

Alternative: load it from a hook

A hook can add the script to the page when your app starts. It does nothing when the key is missing or when the script is already on the page.
src/hooks/useRadar.ts
Call the hook once, at the root of your app:
src/App.tsx

Keep the key out of development

With React Helmet or the hook, store the key in an environment file and leave it empty for development. Without a key, the script is not added to the page, so Radar does not load while you develop.
Create React App only exposes variables whose name starts with REACT_APP_. With Vite, name the variable VITE_RADAR_PROJECT_KEY and read it with import.meta.env.VITE_RADAR_PROJECT_KEY.

Check that it works

Deploy your site, open the published version, load two pages and click a link. The first event should reach your Radar dashboard within a few seconds. If nothing arrives, follow check your installation. When the tag is added by JavaScript rather than written in the HTML, it does not show in the raw page source: look for tracker.js in the Elements panel of your browser’s developer tools instead.