Getting Started with Algolia DocSearch

Learn how to integrate Algolia DocSearch into your documentation.

Algolia DocSearch provides a fast, relevant search experience for documentation sites. It powers the search in this project (Ariadocs). Follow this guide to integrate it into your documentation.

Apply for DocSearch

Algolia provides DocSearch for open-source projects for free. To apply:

  1. Visit the DocSearch Application.
  2. Fill out the form with details about your documentation:
    • Your website URL
    • The selectors for headings and content
    • Your GitHub repository link (if applicable)
  3. Submit your request. Once approved, Algolia will provide:
    • Application ID
    • Search API Key
    • Index Name

Install DocSearch in Your Project

To integrate DocSearch, install the required package:

npm install @docsearch/react@3

Create a Search Component

In your React project, create a Search Component using @docsearch/react:

// src/components/Search.js
import { DocSearch } from '@docsearch/react';
import '@docsearch/css';

export function Search() {
  return (
    <DocSearch
      appId="YOUR_APP_ID"
      indexName="YOUR_INDEX_NAME"
      apiKey="YOUR_SEARCH_API_KEY"
    />
  );
}