all docs

Install on your site

React & Next.js

Load the widget once in your root layout.

Next.js (App Router)

Add the script to app/layout.tsx with next/script so it loads once and survives page navigation.

app/layout.tsx
import Script from "next/script";

export default function RootLayout({ children }: { children: React.ReactNode }) {
  return (
    <html lang="en">
      <body>
        {children}
        <Script
          src="https://yoursearchbox.com/widget/searchbox-cmdk.js"
          strategy="afterInteractive"
          data-bot-id="YOUR_BOT_ID"
          data-api-key="YOUR_WIDGET_KEY"
          data-layout="bottom"
        />
      </body>
    </html>
  );
}

React (Vite, Create React App)

Paste the plain snippet into index.html just before </body>. Don't add it inside a component, because components re-render.

The widget mounts once per page and ignores duplicate tags, so client-side navigation won't create a second copy.

Something unclear? Tell us and we’ll fix this page.