Load the Sleekplan feedback widget in a React app by injecting the install snippet from a useEffect hook, with notes for class components and Next.js.
The Sleekplan widget is a plain script snippet, so it works in any React app. The only thing to get right is when it loads: run it once, after your app has mounted, so the script attaches to a page that already exists.
Add the widget from a useEffect hook in your top-level component (for example App). The empty dependency array [] makes it run once, right after the first render.
Replace YOUR_PRODUCT_ID with the numeric ID from your snippet (leave it unquoted, it is a number).
If your app hot-reloads during development, you may briefly see the launcher appear twice. That is a dev-only side effect of the module reloading, it does not happen in a production build.
In Next.js, use the built-in Script component in your root layout so the snippet loads once across route changes. Give it the afterInteractive strategy and set your product ID before the SDK loads.
import Script from "next/script";export default function RootLayout({ children }) { return ( <html lang="en"> <body> {children} <Script id="sleek-config" strategy="beforeInteractive"> {`window.$sleek=[];window.SLEEK_PRODUCT_ID=YOUR_PRODUCT_ID;`} </Script> <Script src="https://client.sleekplan.com/sdk/e.js" strategy="afterInteractive" /> </body> </html> );}
Because the widget is a client-side script, it only runs in the browser, so there is nothing to render on the server.