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.
<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.htmlinstead. - localhost and
*.netlify.app/*.vercel.apppreviews are allowed automatically.