# Install on React

> For Vite or Create React App, the tag goes in index.html, not in a component that mounts and unmounts.

Section: Installation guides  
Canonical page: https://statsy.co/docs/install/react  
Last updated: 2026-09-15

A plain React app (Vite, Create React App, or any bundler serving one `index.html`) needs the tag in the HTML shell, not inside a component.

## Where it goes

Vite puts the shell at `index.html` in the project root; Create React App at `public/index.html`. Paste the tag inside `<head>`.

```html
<head>
  <meta charset="utf-8" />
  <title>Your startup</title>
  <script defer data-website-id="ws_XXXXXXXX" data-domain="yourstartup.com" src="https://statsy.co/js/script.js"></script>
</head>
```

Do not add the tag from a `useEffect`. An effect runs again on every mount, and in React’s development strict mode it runs twice, so you end up with two copies of the script on the page.

## Confirm it works

Deploy to the real domain and open it. **Live** shows the visitor. Local development on `localhost` is not counted in production, so test on the deployed site.

## Route changes are already tracked

React Router’s browser router navigates with `history.pushState`, which the script patches, so each route is a pageview with no extra code. A hash router (`#/pricing`) is the exception: add `data-hash-routing="true"` to the tag. See [Single-page apps and route changes](https://statsy.co/docs/tracking-script/spa).

Previous: [Install on Next.js](https://statsy.co/docs/install/nextjs)  
Next: [Install on Vue](https://statsy.co/docs/install/vue)