Use the React component through preact/compat, or the vanilla init.
Preact aliases react to preact/compat in most setups, so @usero/sdk/react resolves to the Preact runtime without extra work. If you would rather skip compat, the vanilla init from a useEffect works just as well.
npm install @usero/sdk// Preact aliases 'react' -> 'preact/compat' in vite.config / tsconfig,
// so the React build of the widget runs on Preact unchanged.
import { UseroFeedbackWidget } from '@usero/sdk/react'
export function App() {
return (
<>
{/* your app */}
<UseroFeedbackWidget clientId='YOUR_CLIENT_ID' />
</>
)
}Replace YOUR_CLIENT_ID with the id from your Usero dashboard.
Built for Preact
When react and react-dom are aliased to preact/compat (the standard @preact/preset-vite setup), @usero/sdk/react imports resolve to Preact, no shim of our own needed.
If you do not alias react, import initUseroFeedbackWidget from @usero/sdk and call it from a useEffect with an empty dependency array. Same widget, no compat layer.
Preact is about 3kb, the widget about 12kb gzipped. Both stay small, which is the reason most people reach for Preact in the first place.
preact/compat provides useState and useEffect, which is all the React build of the widget uses internally. Nothing exotic to alias.
Canny embeds a heavy iframe that dwarfs a Preact bundle. The widget adds about 12kb, in the same weight class as Preact itself.
FAQ
Yes, when react and react-dom are aliased to preact/compat, which the default Preact Vite preset does. The React component then runs on the Preact runtime unchanged.
Use the vanilla build instead. Import initUseroFeedbackWidget from @usero/sdk and call it inside a useEffect(() => {...}, []) so it boots once on mount.
Yes. The base widget is about 12kb gzipped and the session-replay plugin is a separate chunk that only loads if you import it.
For no-build htm pages, use the script-tag install instead and call Usero.initUseroFeedbackWidget from a plain script.
Free tier. No credit card. Two-minute install. Cancel by deleting two lines of code.
Install guides