> ## Documentation Index
> Fetch the complete documentation index at: https://tinyanalytics.io/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# React Analytics Integration

> Add tinyanalytics to a Vite or Create React App index.html so one script tracks the full single-page app and its client-side routes.

To add tinyanalytics to a **React** app built with Vite or Create React App, put the tracking snippet in your `index.html`. Because it's a single-page app, one tag in the HTML shell covers every route — client-side navigation is tracked automatically.

## Before you start

* A tinyanalytics site. If you don't have one yet, follow the [Quickstart](/docs/tinyanalytics-quickstart).
* Your site's numeric **site ID**, from **Settings → Tracking** in your dashboard.

## Add the snippet to index.html

Open the `index.html` at the root of your project (Vite) or in `public/` (Create React App), and add the snippet inside `<head>`:

```html index.html theme={null}
<!doctype html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <title>My App</title>
    <script defer src="https://dash.tinyanalytics.io/script.js"
      data-site-id="YOUR_SITE_ID"></script>
  </head>
  <body>
    <div id="root"></div>
  </body>
</html>
```

<Tip>
  Replace `YOUR_SITE_ID` with your real site ID, and copy the full snippet from **Settings → Tracking** if you've toggled any options.
</Tip>

That's it — the script loads once for the whole app and needs no changes as your app grows.

## Client-side routing is tracked automatically

React apps change routes on the client (with React Router or similar), and tinyanalytics records each route change as a new pageview by default (`data-track-spa`). You don't need to hook into your router. See [Track single-page apps](/docs/configure-tinyanalytics-tracking-script#track-single-page-apps) to change this behavior.

## Verify

Run your app, open it in a browser, then check **Realtime** in your dashboard for your visit. See [Verify your setup](/docs/verify-tinyanalytics-installation) for the full check.

<Check>
  Your install is working when your own visit appears in **Realtime** in your dashboard.
</Check>

## Related

<Columns cols={2}>
  <Card title="Install on Next.js" icon="code" href="/docs/integrations/nextjs-analytics">
    A Next.js app instead.
  </Card>

  <Card title="Track custom events" icon="hand-pointer" href="/docs/custom-event-tracking">
    Send events from your components.
  </Card>

  <Card title="Configure the tracking script" icon="sliders" href="/docs/configure-tinyanalytics-tracking-script">
    Every `data-*` option you can set.
  </Card>

  <Card title="Verify your setup" icon="circle-check" href="/docs/verify-tinyanalytics-installation">
    Confirm tracking works.
  </Card>
</Columns>


## Related topics

- [React Native Analytics Integration](/docs/integrations/react-native-analytics.md)
- [Gatsby Analytics Integration](/docs/integrations/gatsby-analytics.md)
- [Remix Analytics Integration](/docs/integrations/remix-analytics.md)
