IntegrationsAstro

Add AI search to your Astro app

What is Astro

Astro is an all-in-one web framework for content-driven websites. With Inkeep, you can Add AI Search & Chat to your landing page, app, blog, or documentation site powered by Astro.

Get an API key

  1. Go to the Inkeep Dashboard
  2. Select your project under Projects
  3. Go to the Integrations tab
  4. Click on Create integration
  5. Select Web
  6. Provide a Name.
  7. Specify a URL for where this integration will be used.
  8. For production API keys, leave Enforce referrer URL checked.
  9. Click on Create
  10. Click the Example < /> button to get your API key and view suggested settings

For local or staging API keys, see here.

Copy and add the apiKey to your environment variables:

.env
INKEEP_API_KEY="INKEEP_API_KEY"

Install the component library

npm install @inkeep/cxkit-react
yarn add @inkeep/cxkit-react

Define React components

Install the @astrojs/react package to use React components:

npx astro add react
bun astro add react
pnpm astro add react
yarn astro add react

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 InkeepSearchBar.tsx file for the Search Bar component.

import React, { useEffect, useState } from "react";
 
export default function InkeepSearchBar() {
  const [SearchBar, setSearchBar] = useState(null);
 
  //...
 
  // load the library asynchronously
  useEffect(() => {
    const loadSearchBar = async () => {
      try {
        const { InkeepSearchBar } = await import("@inkeep/cxkit-react");
        setSearchBar(() => InkeepSearchBar);
      } catch (error) {
        console.error("Failed to load SearchBar:", error);
      }
    };
 
    loadSearchBar();
  }, []);
 
  const searchBarProps = {
    baseSettings,
    aiChatSettings,
    searchSettings,
    modalSettings,
  };
 
  return SearchBar && <SearchBar {...searchBarProps} />;
}
import React, { useEffect, useState } from "react";
import type { InkeepSearchBarProps } from "@inkeep/cxkit-react";
 
export default function InkeepSearchBar() {
  const [SearchBar, setSearchBar] =
    useState<(e: InkeepSearchBarProps) => JSX.Element>();
 
  //...
 
  // load the library asynchronously
  useEffect(() => {
    const loadSearchBar = async () => {
      try {
        const { InkeepSearchBar } = await import("@inkeep/cxkit-react");
        setSearchBar(() => InkeepSearchBar);
      } catch (error) {
        console.error("Failed to load SearchBar:", error);
      }
    };
 
    loadSearchBar();
  }, []);
 
  const searchBarProps: InkeepSearchBarProps = {
    baseSettings,
    aiChatSettings,
    searchSettings,
    modalSettings,
  };
 
  return SearchBar && <SearchBar {...searchBarProps} />;
}

Use the component

Now use the InkeepSearchBar.tsx component in your Astro based website.

// ...
<InkeepSearchBar client:load />
// ...
Note
Note

Use the client:load directive to load and hydrate the InkeepSearchBar.tsx component immediately on page load.

For a full list of customizations, check out the Search Bar documentation.

On this page