Quickstart: React / Next.js
The SDK ships with a ready-to-use React component. Drop it into your root layout and you're done.
Install
npm install @bitpalm/ai-agentsAdd the component
Place <BitPalmAgent /> in your root layout so the widget persists across page navigations.
Next.js (App Router)
// app/layout.tsx
import { BitPalmAgent } from "@bitpalm/ai-agents/react";
export default function RootLayout({ children }: { children: React.ReactNode }) {
return (
<html lang="en">
<body>
{children}
<BitPalmAgent slug="your-agent-slug" token="your-embed-token" />
</body>
</html>
);
}Next.js (Pages Router)
// pages/_app.tsx
import { BitPalmAgent } from "@bitpalm/ai-agents/react";
export default function App({ Component, pageProps }) {
return (
<>
<Component {...pageProps} />
<BitPalmAgent slug="your-agent-slug" token="your-embed-token" />
</>
);
}Vite / CRA / any React app
// App.tsx
import { BitPalmAgent } from "@bitpalm/ai-agents/react";
export default function App() {
return (
<>
<YourRoutes />
<BitPalmAgent slug="your-agent-slug" token="your-embed-token" />
</>
);
}Component props
| Prop | Type | Default | Description |
|---|---|---|---|
slug | string | — | Required. Your agent slug from the dashboard. |
token | string | — | Required for restricted agents. |
locale | string | auto | "en", "de", "ar". Falls back to document.documentElement.lang. |
baseUrl | string | https://agents.bitpalm.ai | Only for self-hosted. |
zIndex | number | 9999 | z-index for the iframe and button. |
autoIdentify | boolean | true | Auto-capture form fields on submit. |
Server-side rendering
The component is client-only and safely no-ops during SSR. You don't need dynamic() or useEffect wrappers.
Programmatic control
To call methods like identify(), context(), send(), open(), etc., use the Vanilla SDK approach instead — it gives you a widget instance reference. Or fire browser events:
useEffect(() => {
if (user) {
window.dispatchEvent(
new CustomEvent("bitpalm-identify", {
detail: {
slug: "your-agent-slug",
externalUserId: user.id,
email: user.email,
name: user.name,
},
})
);
}
}, [user]);See Identify and Context for full details.