Install Wayhint in React (Next.js or Vite)
Pepper notices client-side route changes (pushState, popstate), so a guided goal keeps going as your SPA navigates.
You need a site key, and your domain on its allowlist. See before you start. Replace YOUR-GUIDE-HOST and YOUR_SITE_KEY in the snippets.
Next.js (App Router)
Load the script once in the root layout.
lazyOnloadkeeps it off the critical path.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://YOUR-GUIDE-HOST/widget/guide.js" data-site-key="YOUR_SITE_KEY" strategy="lazyOnload" /> </body> </html> ); }Vite (or Create React App)
Add the script tag to
index.html, before</body>.index.html <div id="root"></div> <script type="module" src="/src/main.tsx"></script> <script src="https://YOUR-GUIDE-HOST/widget/guide.js" data-site-key="YOUR_SITE_KEY" async></script> </body>Optional: start a guide from your own button
Once ready, the widget exposes
window.Wayhintwithask(goal),stop(),open()anddestroy(), and fireswayhint:readyonwindow. Check it exists before calling it.HelpButton.tsx declare global { interface Window { Wayhint?: { ask(goal: string): void; stop(): void; open(): void }; } } export function HelpButton() { return ( <button onClick={() => window.Wayhint?.ask('export my invoices')}> Show me how to export </button> ); }Or: the @wayhint/loader package
Instead of the script tag,
@wayhint/loaderadds it for you and gives you a component and a hook. It resolves when the guide is ready, reports why it did not start, and removes the guide when the last component unmounts (StrictMode-safe). It is in the source repository underintegrations/npm, not on npm yet.app/providers.tsx 'use client'; import { Wayhint, useWayhint } from '@wayhint/loader/react'; export function Guide() { return <Wayhint siteKey="YOUR_SITE_KEY" widgetUrl="https://YOUR-GUIDE-HOST/widget/guide.js" />; } export function HelpButton() { const { api, ready } = useWayhint({ siteKey: 'YOUR_SITE_KEY', widgetUrl: 'https://YOUR-GUIDE-HOST/widget/guide.js' }); return <button disabled={!ready} onClick={() => api?.ask('export my invoices')}>Show me how</button>; }
Check it works
Open the page. An Ask Pepper button appears in the bottom corner and Pepper waves. In the browser console, window.Wayhint should be defined. If nothing appears, check the console for [web-assistant] messages: an unknown site key or a domain missing from the allowlist are the usual causes.
Next
- Hide sensitive areas with
data-guide-privateanddata-guide-ignore(overview). - Add your own “Show me” buttons with
Wayhint.ask()(example). - Read what the guide sees, or pick a plan.