IntegrationsNextjs

Add Embedded Chat to Next.js

Copy page

Integrate Inkeep's embedded chat into your Next.js application for seamless user interaction.

What is Next.js

Next.js is a React full-stack app development framework. You can use Inkeep's React component library to Add AI Search & Chat functionality to apps or documentation and marketing sites built with Next.js.

Get an API key

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

Copy and add the apiKey to your environment variables:

.env
NEXT_PUBLIC_INKEEP_API_KEY="INKEEP_API_KEY"

Install the component library

Customize your settings

Define your Inkeep settings.

const baseSettings = {
  apiKey,
  primaryBrandColor: "#26D6FF", // your brand color, widget color scheme is derived from this
  organizationDisplayName: "Inkeep",
  // ...optional settings
};
 
const modalSettings = {
  // optional settings
};
 
const searchSettings = {
  // optional settings
};
 
const aiChatSettings = {
  // optional settings
  aiAssistantAvatar: "/img/logo.svg", // use your own AI assistant avatar
  exampleQuestions: [
    "Example question 1?",
    "Example question 2?",
    "Example question 3?",
  ],
};
import type {
  InkeepAIChatSettings,
  InkeepSearchSettings,
  InkeepBaseSettings,
  InkeepModalSettings,
} from "@inkeep/cxkit-react";
 
const baseSettings: InkeepBaseSettings = {
  apiKey,
  primaryBrandColor: "#26D6FF", // your brand color, widget color scheme is derived from this
  organizationDisplayName: "Inkeep",
  // ...optional settings
};
 
const modalSettings: InkeepModalSettings = {
  // optional settings
};
 
const searchSettings: InkeepSearchSettings = {
  // optional settings
};
 
const aiChatSettings: InkeepAIChatSettings = {
  // optional settings
  aiAssistantAvatar: "/img/logo.svg", // use your own AI assistant avatar
  exampleQuestions: [
    "Example question 1?",
    "Example question 2?",
    "Example question 3?",
  ],
};

Define the component

Next, create an InkeepEmbeddedChat.tsx component file for our Embedded Chat component.

Note
Note

For Next.js apps that use App Router, use the "use client" directive at the top of the file to load the widget client side.

import dynamic from "next/dynamic";
 
const EmbeddedChat = dynamic(
  () => import("@inkeep/cxkit-react").then((mod) => mod.InkeepEmbeddedChat),
  {
    ssr: false,
    // loading: () => <div>loading...</div>, // optional: loading animation component
  }
);
 
function InkeepEmbeddedChat() {
  const embeddedChatProps = {
    baseSettings,
    aiChatSettings,
  };
 
  return <EmbeddedChat {...embeddedChatProps} />;
}
 
export default InkeepEmbeddedChat;
import dynamic from "next/dynamic";
import { InkeepEmbeddedChatProps } from "@inkeep/cxkit-react";
 
const EmbeddedChat = dynamic(
  () => import("@inkeep/cxkit-react").then((mod) => mod.InkeepEmbeddedChat),
  {
    ssr: false,
    // loading: () => <div>loading...</div>, // optional: loading animation component
  }
);
 
function InkeepEmbeddedChat() {
  const embeddedChatProps: InkeepEmbeddedChatProps = {
    baseSettings,
    aiChatSettings,
  };
 
  return <EmbeddedChat {...embeddedChatProps} />;
}
 
export default InkeepEmbeddedChat;

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

On this page