Add the SDK via the scripts array in docusaurus.config.js.
Docusaurus has a first-class scripts option in its config, so you do not have to swizzle a component. Add the SDK script there and a small client module to call init, and the widget ships on every docs page.
npm install @usero/sdkimport { initUseroFeedbackWidget } from '@usero/sdk'
let widget
export function onRouteDidUpdate() {
if (widget) return
widget = initUseroFeedbackWidget({ clientId: 'YOUR_CLIENT_ID' })
}export default {
// ...
clientModules: [require.resolve('./src/clientModules/usero.js')],
}Replace YOUR_CLIENT_ID with the id from your Usero dashboard.
Built for Docusaurus
Docusaurus clientModules run in the browser on every route. Registering one is cleaner than swizzling the Layout component just to add a script.
onRouteDidUpdate fires on every navigation. The widget guard variable ensures it initializes a single time, not once per docs page view.
Client modules only run in the browser. The static HTML Docusaurus builds for SEO never executes the widget code.
Docusaurus is a single-page app after first load. The init-once guard keeps the widget alive as readers click between docs.
Featurebase loads a script and waits for a mount target. The vanilla SDK renders its own trigger from the init call, ideal for a docs SPA.
FAQ
No. Use a client module registered in clientModules. It runs in the browser on every route, which is simpler and update-safe compared to swizzling Layout.
onRouteDidUpdate fires on every navigation. Without the guard you would create a new widget per page view. The guard keeps exactly one instance.
No. Client modules only execute in the browser, so the prerendered HTML Docusaurus generates for search engines is unaffected.
Yes. Read the location inside onRouteDidUpdate and only call init when the path starts with your docs base path.
Free tier. No credit card. Two-minute install. Cancel by deleting two lines of code.
Install guides