data-api-key to your root layout.
- Next.js (App Router)
- React
- Vue 3
- Plain HTML
Use To start the widget from a component, remove
next/script with the data attributes. Add the component to your root layout. The widget then shows on every page.app/layout.tsx
data-api-key from the Script element. Then use the component from the React tab. Add 'use client' at the top of the component file, because init runs only in the browser.pl_live_... with your API key. Add your site to Allowed origins in the dashboard.
TypeScript
The React and Vue samples usewindow.PaperlinkAIChatQueue and the PaperlinkAI namespace. Add the types file to your project, as TypeScript types explains. Without it, TypeScript reports that these names do not exist.
Single-page apps
A floating widget stays on the page when your router changes the route. The widget is attached todocument.body, so the conversation continues on the next route. Start it once, in the root layout or the root component.
For an inline widget on one route, start it in the component of that route. Call destroy() when the component unmounts, as the samples above do. If the visitor returns to the route, the new widget shows the same conversation.
Inline mode
Put the widget inside a container on your page instead of a floating launcher.