# How to add an AI chatbot to a React + Vite app

**Open `index.html` in the project root (not in `src/`) and paste the script tag just before `</body>`.** The widget sits outside your React tree, so it won't re-render and it doesn't depend on routing.

```html
<body>
  <div id="root"></div>
  <script type="module" src="/src/main.tsx"></script>
  <script src="https://onelinechat.com/widget.js" data-key="olc_pub_YOUR_KEY" async></script>
</body>
```

## Notes

- This works the same way for Vue, Svelte, Solid, and any other Vite template.
- Using Create React App? Put the line in `public/index.html` instead.
- localhost and `*.netlify.app` / `*.vercel.app` previews are allowed automatically.

---
Source: https://onelinechat.com/install/react-vite · Last updated: 2026-11-20 · All docs: https://onelinechat.com/llms.txt
