Get started
Install the script
Add Usercase once, in the head of every page. It loads asynchronously and does not block your page.
Script tag
Copy your install code from Settings → Installation in the dashboard. It already contains your project ID. Paste it before </head> on every page.
<script> (function () { var w = window; if (!w.Usercase) { w.Usercase = {}; } w.Usercase.project = "YOUR_PROJECT_ID"; function l() { if (w.UsercaseInitialized) { return; } w.UsercaseInitialized = true; var s = document.createElement("script"); s.type = "text/javascript"; s.async = true; s.src = "https://app.usercase.io/plugin/1.0.1/eb-plugin-web.js"; var x = document.getElementsByTagName("head")[0]; if (x) { x.appendChild(s); } } if (document.readyState === "complete") { l(); } else { w.addEventListener("DOMContentLoaded", l); w.addEventListener("load", l); } })(); </script>
npm
Install the package and call init once, when your app starts.
npm install usercase
import Usercase from 'usercase'; Usercase.init({ project: 'YOUR_PROJECT_ID' });
import { useEffect } from 'react'; import Usercase from 'usercase'; function App() { useEffect(() => { Usercase.init({ project: 'YOUR_PROJECT_ID' }); }, []); return <div>My App</div>; }
'use client'; import { useEffect } from 'react'; import Usercase from 'usercase'; export default function UsercaseProvider({ children }) { useEffect(() => { Usercase.init({ project: 'YOUR_PROJECT_ID' }); }, []); return <>{children}</>; }
<script setup> import { onMounted } from 'vue'; import Usercase from 'usercase'; onMounted(() => { Usercase.init({ project: 'YOUR_PROJECT_ID' }); }); </script>
Options
| Option | Type | Description |
|---|---|---|
project | string | Required. Your project ID. |
requireConsent | boolean | Wait for Usercase.consent(true) before starting. See Consent. |
Let your agent install it
With the Usercase plugin connected, ask your coding agent to install it. It finds your root layout, adds the script once, shows you the diff and opens your local site to check that it loads. It does not commit or deploy.
Install Usercase on this site
/mcp__usercase__install
$usercase:install