Small client boundary
Mark only the interactive chat module with use client instead of moving an entire page or layout to the browser.
Use @openstaticfish/chattybox inside a focused client boundary while the rest of your App Router application stays server-rendered. ChattyBox handles retrieval, citations, conversations, and scaling.
ChattyBox crawls your existing documentation, indexes the content for retrieval, and embeds a chatbot that answers using your docs instead of generic model memory.
Install @openstaticfish/chattybox in the Next.js application.
Add the public widget API key and API URL as NEXT_PUBLIC environment variables.
Create a client component for chat state and browser interaction.
Import that client component from a Server Component page or layout.
Three-step launch
Keep the SDK at the client edge where chat interaction happens and preserve Server Components for the rest of the application.
Mark only the interactive chat module with use client instead of moving an entire page or layout to the browser.
Use a browser-safe project key with allowed origins; never expose management credentials through NEXT_PUBLIC variables.
Render messages and citations in your own navigation, account area, docs shell, or support workflow.
Avoid adding route handlers solely to proxy a managed browser API unless your product has a concrete server-side requirement.
The SDK uses fetch and browser-visible project credentials, so initialize it in a client module. Keep secrets and management APIs out of NEXT_PUBLIC variables.
'use client';
import { useState } from 'react';
import { Chattybox } from '@openstaticfish/chattybox';
const chattybox = new Chattybox({
apiKey: process.env.NEXT_PUBLIC_CHATTYBOX_API_KEY!,
baseUrl: process.env.NEXT_PUBLIC_CHATTYBOX_API_URL!,
});
export function Chat() {
const [answer, setAnswer] = useState('');
async function ask(message: string) {
const response = await chattybox.sendMessage({ message });
setAnswer(response.message);
}
return <div aria-live="polite">{answer}</div>;
}Review the underlying package and managed infrastructure boundary.
See component and state patterns shared by React applications.
Review response fields, follow-up conversations, and errors.
Use next/script and the maintained widget UI for a no-build chat experience.
Yes. Use it in a client component for interactive chat state and render that component from an App Router page or layout.
Not for the normal browser integration. Public widget keys are designed for client use and can be restricted to approved origins.
The public widget key identifies a project but is not a management credential. Restrict it to your production and preview origins, and never expose administrative secrets.
Yes. The hosted installation guide shows the next/script path when you prefer a maintained UI instead of a custom SDK interface.
No credit card required. Your content is not used for model training.
Free tier. No card needed.