Algolia Search

An overview of the Algolia Search integration.

This document provides an overview of how we use Algolia's InstantSearch in our codebase, how to index your content, and the necessary environment variables.

Algolia InstantSearch

Algolia is a hosted search engine capable of delivering real-time results from the first keystroke. It allows you to build search experiences in your websites and applications.

We use Algolia's InstantSearch to provide a powerful, out-of-the-box, search experience. You can sign up for a free account at

Creating an Index

Once you have created an account, you will need to create an index. An index is a collection of records that you want to search. In our case, we have created an index called docs.

This name should match the value of the NEXT_PUBLIC_ALGOLIA_INDEX_NAME environment variable.

Environment Variables

The following environment variables are required for the Algolia integration to work:

  • NEXT_PUBLIC_ALGOLIA_APP_ID → This is the application ID for Algolia.
  • NEXT_PUBLIC_ALGOLIA_SEARCH_API_KEY → This is the search API key for Algolia.
  • NEXT_PUBLIC_ALGOLIA_INDEX_NAME → This is the index name for Algolia.
  • ALGOLIA_ADMIN_API_KEY → This is the admin API key for Algolia, used for search functionality.

You can find these values in the API Keys section of your Algolia settings.

Indexing Your Content

To index your content, we use a script that reads all the markdown files in the content directory, extracts the necessary data, and then saves it to the Algolia index.

The script is located in index-docs.ts and can be executed by running the following command in your terminal:

1bun run ./index-docs.ts

This has to be done every time you add new content to the content directory. Otherwise, the new content will not be searchable.

If you deploy the site to Vercel, the script will be executed automatically as part of the build process during deployment.

Last updated 13 days ago
Scroll to top
Was this article helpful?