IntegrationsFumadocs

Add Chat Button to Fumadocs

Learn how to integrate Inkeep's chat button into your Fumadocs documentation for real-time user assistance and enhanced documentation interactivity.

What is Fumadocs

Fumadocs is an open source documentation framework, powered by Next.js App Router.

Get an API key

Follow these steps to create an API key for your web integration.

Initialize the widget

Note
Note

You will need to replace REPLACE_WITH_YOUR_INKEEP_API_KEY with your actual Inkeep API key in the code below.

Create an inkeep-script.tsx client component in your Fumadocs project.

inkeep-script.tsx
"use client";
 
import { useEffect, useState } from "react";
import { InkeepChatButton, type InkeepChatButtonProps } from "@inkeep/cxkit-react";
 
export function InkeepScript() {
  // color mode sync target
  const [syncTarget, setSyncTarget] = useState<HTMLElement | null>(null);
 
  // We do this because document is not available in the server
  useEffect(() => {
    setSyncTarget(document.documentElement);
  }, []);
 
  const config: InkeepChatButtonProps = {
    baseSettings: {
      apiKey: "REPLACE_WITH_YOUR_INKEEP_API_KEY", // required - replace with your own API key
      primaryBrandColor: "#26D6FF", // your brand color, widget color scheme is derived from this
      organizationDisplayName: "Inkeep",
      // ...optional settings
      colorMode: {
        sync: {
          target: syncTarget,
          attributes: ["class"],
          isDarkMode: (attributes) => !!attributes.class?.includes("dark"),
        },
      },
    },
    modalSettings: {
      // optional settings
    },
    searchSettings: {
      // optional settings
    },
    aiChatSettings: {
      // optional settings
      aiAssistantAvatar: "https://mydomain.com/mylogo", // use your own AI assistant avatar
      exampleQuestions: [
        "Example question 1?",
        "Example question 2?",
        "Example question 3?",
      ],
    },
  };
 
  return <InkeepChatButton {...config} />;
}

Then import it in the <body /> of your root layout.tsx file.

layout.tsx
import { InkeepScript } from "@/app/inkeep-script";  
import { SearchBar } from "@/app/SearchBar";
import { RootProvider } from "fumadocs-ui/provider";
import "fumadocs-ui/style.css";
import { Inter } from "next/font/google";
import Script from "next/script";
import type { ReactNode } from "react";
 
const inter = Inter({
  subsets: ["latin"],
});
 
export default function Layout({ children }: { children: ReactNode }) {
  return (
    <html lang="en" className={inter.className} suppressHydrationWarning>
      <body
        style={{
          display: "flex",
          flexDirection: "column",
          minHeight: "100vh",
        }}
      >

        <InkeepScript />
        <RootProvider>{children}</RootProvider>
      </body>
    </html>
  );
}

For a full list of customizations, check out the Chat Button documentation.

On this page