Bring your own JS to Algolia Docsearch

Published in Programming on Feb 14, 2021

This article covers how to use Algolia Docsearch as if it were your own Algolia index.

This is actually really simple, so this article will be short.

The use case for this is when you have an existing custom UI component that uses your own Algolia index, but then you switch to the Docsearch service. I did this with Lean, because as much as I tried to get Laravel Scout to do what I wanted, it's just not a good fit for articles. Scraping the rendered HTML with an engine like Docsearch is much better.

So, to do this, simply use this config:

let index = algoliasearch('BH4D9OD16A', 'your-api-key').initIndex('your-index-name');

The app name is the same for all Docsearch configs, and the API key and index name are in the email you received from Docsearch. The app is the key part here, because it's not documented anywhere.

Newsletter

You will be notified whenever I publish an article about the topics you selected. Unsubscribe anytime.

Comments

Your comment will appear once it's approved (to fight spam).