IntegrationsFumadocs

Add Chat Button to Fumadocs

Copy page

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 assistant.

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.

Positioning

We support customization of styles via custom css in baseSettings, you can style "Ask AI" button by targetting it's class as so:

const baseSettings = {
  theme: {
    //...Other base Settings

    // Custom styles injection
    styles: [
      {
        key: "custom-theme",
        type: "style",
        value: `
         .ikp-chat-button__container {
           // Position the Ask-AI button on the left
           left: 1.5rem;
         }
       `,
      },
    ],
  },
};

You can find more information in the Custom Styles documentation.