---
url: https://simpledatalogs.com/docs/quickstarts/react-vite.md
description: >-
  Add simpledatalogs to a React app on Vite in one minute, with page views,
  sessions and errors captured by one line.
---

# React (Vite)

## Install

```sh
npx simpledatalogs init
npm install simpledatalogs
```

`init` adds the key to `.env.local` and two lines to `src/main.jsx` (or `.tsx`), after showing you the diff.

## Or by hand

```sh
# .env.local
VITE_SIMPLEDATALOGS_KEY=sdl_pub_…
```

```jsx
// src/main.jsx, after the other imports
import { init } from 'simpledatalogs'

init({ key: import.meta.env.VITE_SIMPLEDATALOGS_KEY, autocapture: true })
```

## Send everything, or only what you choose

* **Everything:** `autocapture: true`.
* **Only your own events:** drop it and track what matters:

```js
// analytics.js
import { init } from 'simpledatalogs'

export const sdl = init({ key: import.meta.env.VITE_SIMPLEDATALOGS_KEY })
```

```jsx
sdl.track('checkout_started', { items: cart.length })
```

## In the first minute

* `session_start` and a `page_view` with `path`, `title`, `referrer` and `utm_*`.
* A `page_view` on every React Router (or any `history.pushState`) navigation that changes the path.
* Uncaught errors and unhandled rejections on the **Logs** tab.

## Autocapture defaults

| Feature | `autocapture: true` |
|---|---|
| Page views, including SPA routes | on |
| Sessions | on |
| Errors and unhandled rejections | on |
| Outbound link clicks | off |
| Do Not Track / Global Privacy Control | respected |

See the [JavaScript SDK](/sdks/javascript#autocapture) for every flag.
